I have clarified my previous question. How can I retrieve multiple data simultaneously? (Parse DB, iOS)
Hello, I am new to Parse and databases, and I am struggling a bit here.
On the view, there are 4 buttons and a label.
So basically what I want to do is retrieve first the object of column @"A" (at the same time displaying the data on the label) , and then retrieve the attributes of the same row. When I press any other buttons, they should display the queried attribute which is in the same row with @"A"
But currently this code is running a query every time I press the button, so each four is a mess sending different random datas to the view.
Also, the log executes an error: Warning: A long-running Parse operation is being executed on the main thread. Break on warnParseOperationOnMainThread() to debug.
I would be really happy if somebody can help me out with the solution for this.
PFQuery *query = [PFQuery queryWithClassName:@"DataClass"]; //get a data(object) randomly int count = [query countObjects]; int randomCount = arc4random() % count; query.skip = randomCount; [query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) { if (!error) { //retrieving data... but asynchronously! NSString *getTheStr1 = object[@"A"]; NSString *getTheStr2 = object[@"B"]; NSString *getTheStr3 = object[@"C"]; NSString *getTheStr4 = object[@"D"]; //when I press a button, each shows a different text on the label. UIButton *button = (UIButton *)sender; switch ([button tag]) { case 1: Label.text = [NSString stringWithFormat:@"%@", getTheStr1]; break; case 2: Label.text = [NSString stringWithFormat:@"%@", getTheStr2]; break; case 3: Label.text = [NSString stringWithFormat:@"%@", getTheStr3]; break; case 4: Label.text = [NSString stringWithFormat:@"%@", getTheStr4]; } } }];