I’ve got a NSDictionary and I’d like put all of it’s objects and keys into a NSString, so that I can finally display them in a label like this:
key1: object1
key2: object2
key3: object3
… …
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Build the string and then set it to the labels text.
Note
The docs (String Programming Guide) for the
%@format specifier state:So if these are your own custom objects in the dictionary you will most likely need to override the
descriptionmethod to provide more meaningful outputUpdate
You mention that you need your output sorted by keys – dictionaries are not ordered so you will have to do it differently – this example assumes that your keys are strings