在 UILabel 中显示来自 NSMutableArray 的对象

Display object from NSMutableArray in UILabel

我正在尝试在我的 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.";
                }
            );
        };

正如你所说,它是一个数组,所以你需要先提供你想要获取的dict的索引:

self.userBio.text = self.mapFriendData[0][@"field_friendbio"][@"und"][0][@"safe_value"];
                                       ^
                                    "index of your field_friendbio dict"