Sunday, 29 September 2013

Using Parse.com to retrieve a new array iOS

Using Parse.com to retrieve a new array iOS

I'm trying to use the parse.com data browser to inset a new string array
into my code.
So if I've got a code with an array of @"blue", @"yellow", @"black", nil
then how can I change it to @"white", @"gold", @"brown", nil ?
In the app, I have the user press a button and one of said string value
appears at random. I would like to put a new array on a backend to have
new values so that I don't have to update the app every time.
Is there an example of how to do this? I haven't been able to get the Data
Browser to replace the array in my code with the array in the data
browser.
I've got:
PFQuery *query = [PFQuery queryWithClassName:@"colorArray"];
self.colors = [query findObjects];
But it crashes when I try to retrieve the values of the array when it gets
to this part of the code in a later method -
NSUInteger index = arc4random_uniform(self.colors.count];
self.colorLabel.text = [self.colors objectAtIndex:index];
self.colors, by the way, is synthesized from the header file as an array.
It looks like the code doesn't understand the "index" part of the equation
when it tries to set the self.colorLabel.text using the obectAtIndex
Am I doing this right? Thanks for any help anyone can give.

No comments:

Post a Comment