我正在尝试在我的UILabel中显示字段'field_friendbio'。我应该怎么写这一行? self.mapFriendData是一个NSMutableArray(数据从前一个控制器传递给self.mapFriendData)。
现在,我有:
·H
@property (nonatomic, strong) NSMutableArray *mapFriendData;
的.m
self.userBio.text = self.mapFriendData[@"field_friendbio"][@"und"][0][@"safe_value"];
但这只适用于NSDictionary。
数据输出:
"field_friendbio" = {
und = (
{
format = "<null>";
"safe_value" = "Hi my name is Blair. ";
value = "Hi my name is Blair. ";
}
);
};
在我将其调用到UILabel之前,mapFriendData是:
THIS IS MAP FRIEND DATA (
{
body = (
);
changed = 1462155513;
cid = 0;
comment = 2;
"comment_count" = 0;
created = 1462155513;
data = "a:1:{s:7:\"overlay\";i:1;}";
"field_address1" = {
und = (
{
format = "<null>";
"safe_value" = "1275 This Street, LA, California";
value = "1275 This Street, LA, California";
}
);
};
"field_friendbio" = {
und = (
{
format = "<null>";
"safe_value" = "Hi my name is Blair.";
value = "Hi my name is Blair.";
}
);
};
答案 0 :(得分:0)
正如你所说,它是一个数组,所以你需要提供你想要获得的字典的索引:
self.userBio.text = self.mapFriendData[0][@"field_friendbio"][@"und"][0][@"safe_value"];
^
"index of your field_friendbio dict"