title: How to get elements from an array of pointers from Parse - Using Swift
body: <p><strong>Context</strong></p>
  
  <p>I use Parse.com as my backend. Parse lets you have the ability to store an array of pointers to another one of your classes. In my case, for each user, if they are a business owner, I have an array of pointers to the businesses they own. The array looks like this: <code>[{"__type":"Pointer","className":"Businesses","objectId":"auUS4I8ILh”}]</code></p>
  
  <p>Now, in my application, I have a class that allows users to post to a timeline. If the user is also a business owner, it will allow the user to decide between posting as themselves or as the business they own. In order to do this, when I query for the user that's posting, I include the key that holds the array of pointers in my "_User" class. </p>
  
  <p><strong>Issue</strong></p>
  
  <p>Okay so my issue is when I'm trying to get the information out of the array of pointers. If I print the current user out to the console, it clearly shows the information in that column, as shown below. However, I can't figure out a good way to access this information. </p>
  
  <p>Originally, I tried this:</p>
  
  <pre><code>if let businessOwner: [AnyObject] = self.currentUser.objectForKey("BusinessOwner") as! [AnyObject] {...}
  </code></pre>
  
  <p>After this, the next part of the code is supposed to get the object id's by iteration so that I can query for the business' information: </p>
  
  <pre><code>for business in businessOwner {
     objectIDArray.append(business.objectId as! String)
  }
  </code></pre>
  
  <p>This originally worked when there was only one business in the array of pointers, but eventually even that stopped working. I've tried changing some things here and there, but the two problems I continually run into are: 1) the <code>if...let</code> statement just falls through, indicating that there was nothing to put into the <code>businessOwner</code> array (which I know isn't true because I can see the print out in the console), or 2) that the <code>businessOwner</code> array is instantiated and filled, but then the program crashes when trying to access the object id of the business, presumably related to the way I'm trying to access the string that is the object's id. </p>
  
  <p>For clarification's sake, here is what the dictionary looks like after the <code>business</code> is assigned during iteration:<img src="https://i.stack.imgur.com/kCFql.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/pgZ65.png" alt="Printed description of the &quot;BusinessOwner&quot; array of pointers."></p>
  
  <p>So in essence, what do I have to do to assign the objects in my "BusinessOwner" column to an array, and <em>then</em>, how can I get the object id's in order to use them for my query? I've been fighting this issue for a couple of days. If anyone could help me out here it would be awesome. </p>