Grab NSString from Parse.com and paste it into UILabel

不羁的心 提交于 2019-12-11 03:56:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!