I have an NSMutableArray object that contains NSString objects. The mutable array object is called _usersToAddToFriendsList
. When I am done adding NSString objects to it, I run the following code for Parse.com:
[PFUser currentUser];
PFQuery *query = [PFQuery queryWithClassName:@"_User"];
[query whereKey:@"username" equalTo:_userSubmittedUsername];
[query getObjectInBackgroundWithId:_objectId block:^(PFObject *object, NSError *error) {
object[@"friends"] = _usersToAddToFriendsList;
[object saveInBackground];
}];
The most important part is this statement: object[@"friends"] = _usersToAddToFriendsList;
This takes my NSMutable array and places it inside the "friends" column in my Parse.com database. When I created this column in Parse, I set it's "type" to "array".
All of this works perfectly and I can see that the contents of my mutable array have been placed in the "friends" column in the database.
Here's the problem though. Later on, when I query for the "friends" column I use the method call of findObjectsInBackgroundWithBlock
and this places the object returned by the server into an NSArray object called "objects".
My problem is that this means that I now have an array called "objects" that contains my original mutable array with my NSStrings.
I need to loop through the string values of my original NSMutableArray, but I don't know how to get to them because my original mutable array is contained inside this new NSArray returned by the server.
I have tried playing around with various multi-dimensional array solutions that people provided in my previous stack overflow question: Need to loop through an array that is inside of another array
But it never works and it always crashes in xcode and says:
-[PFUser countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance
This makes me think that this problem needs a solution specifically tailored to how Parse.com works.
I just want to be able access and loop through the string values that I originally stored in my NSMutableArray.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…