Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Matthew Waller
1,698 PointsUsing Parse.com to update an array?
So I'm working through the set of parse.com lessons for iOS. I'm wondering, is there a way to use Parse.com to update an NSArray of strings? For instance, we have a set amount of responses in the Crystal Ball app, for those who have done the project.
Would there be a way to add or subtract responses from the NSArray of responses using Parse.com, so that a developer wouldn't have to update the entire app each time to get new responses?
I'm been browsing Parse's developer guidelines here ( https://parse.com/docs/ios_guide#objects/iOS ), but I can't think a way to make the above scenario happen.
Any tips or ideas?
2 Answers
Matthew Waller
1,698 PointsDid some asking around the Internet and tested it out. The rest would look like this
NSUInteger index = arc4random_uniform(predictions.count);
PFObject *predictionPFObject = [predictions objectAtIndex: index];
self.fortuneLabel.text = [predictionPFObject objectForKey:@"predictions"];
where @"predictions" is the name of the column filled with predictions.
Amit Bijlani
Treehouse Guest TeacherYou would have to create a table to store all the predictions. Let's assume you call this table "Predictions".
PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
NSArray *predictions = [query findObjects];
Matthew Waller
1,698 PointsI'm getting an error in the app I'm using this for. It's saying "[PFObject length]: unrecognized selector sent to instance 0xbe6ab70"
When I debug, it's failing at the self.predictionArray objectAtIndex:index part of the code.