【发布时间】:2013-10-08 16:37:21
【问题描述】:
我有一个名为 itemDict 的 NSDictionary 并且在打印时
NSLog(@"itemDictValues:%@",itemDict);
输出格式如下:
itemDictValues:
GTLPlusPerson 0xab821e0:
{etag:""LTv_6IJISeUQGTVXLjMeOtebkoM/eup2crXcelmpMFKesXWlGkJjCiE"" kind:"plus#person" id:"1145282979128841" objectType:"person" displayName:"FirstName LastName" image:{url} url:"https://plus.google.com/1145282979128841"}
据此,我需要将 id、displayName 和 url 对应的值提取到我的 NSString 变量中,格式如下
profileId=1145282979128841;
Name=FirstName LastName;
Profilepic=https://plus.google.com/1145282979128841;
我该怎么做?
【问题讨论】:
-
你说 itemDict 是一个 NSDictionary,但它似乎并不是基于你说它没有响应 objectForKey。你能展示一些关于 itemDict 是如何设置的代码吗?它实际上不是一个 NSDictionary,而是一个 GTLPlusPerson?
-
NSMutableArray *friends=[NSMutableArray 数组]; for(NSDictionary * itemDict in peopleFeed.items) { SocialProfile *friend=[[SocialProfile alloc] initWithDictionary: itemDict socialMedia:kSocialMediaGooglePlus]; [朋友添加对象:朋友]; }
-
GTLPlusPeopleFeed *peopleFeed,是 peopleFeed 的定义方式。
标签: ios objective-c nsstring nsdictionary google-plus