NSPredicate IN query from array elements
<p>Apologies for a quirky title. I have an array of Ints and I would like to define an NSPredicate that will filter out items with connectionType equals to a value contained in the array. </p>

<p>So basically something like: </p>

<pre><code>fetchRequest.predicate = NSPredicate(format: "connectionType IN { all items in array }
</code></pre>

<p>I've found some Objective C examples that I think deals with this, but I just got into iOS development and have only worked with Swift, so some help here would be greatly appreciated :)</p>

<p>I tried doing this:</p>

<pre><code> fetchRequest.predicate = NSPredicate(format: "connectionType IN \(myIntArray)"
</code></pre>

<p>However, this returns an NSInvalidArgumentException. I feel I'm close though. </p>

<pre><code>NSInvalidArgumentException', reason: 'Unable to parse the format string "connectionType IN [28, 28]" 
</code></pre>

<p>If I do the following:</p>

<pre><code>fetchRequest.predicate = NSPredicate(format: "connectionType IN %@", myArray)
</code></pre>

<p>I get this error instead:</p>

<pre><code>NSInvalidArgumentException', reason: 'unimplemented SQL generation for predicate : (connectionType IN {28, 28})'
</code></pre>