问题
I'd like to grab a NSString from the Parse.com and paste it into a Label in my iOS App.
Does anyone know how to do so ? I'm having massive problems with it :/
Thanks in advance
回答1:
The counter-question is "Which NSString do you want to get"? I assume it's some property of a PFObject that you want to display, right? What makes this property so interesting?
Let's say you want to display the title of a Book whose author is Hemmingway.
First you want to find the object:
PFQuery *query = [PFQuery queryWithClassName:@"Book"]; // I want to find a book
[query whereKey:@"author" equalTo:@"Hemmingway"]; // authored by hemmingway
PFObject *book = [query findFirstObject]; // go get it!
Then you just read its properties with objectForKey
myLabel.text = [book objectForKey:@"title"];
Check out the iOS guides for more advanced questions. If you plan to display many properties of many PFObjects, you might want to check out the PFQueryTableViewController
来源:https://stackoverflow.com/questions/10776809/grab-nsstring-from-parse-com-and-paste-it-into-uilabel