iphone - 在以下示例中如何从 NSSArray 元素获取值?

标签 iphone objective-c ios

我有一个 NSArray,所以当我这样做时:

NSLog(@"%@", [jokesArray description]);

我得到以下信息:

(
        {
        "_id" =         {
            "$id" = 4e91fd49c7e24cda74000000;
        };
        author = draper;
        comments =         (
                        {
                author = adias;
                comment = "amazing again";
            }
        );
        created =         {
            sec = 1318118400;
            usec = 0;
        };
        text = "This is a random post again";
        title = "post # 2";
        type =         (
            punjabi
        );
    },
        {
        "_id" =         {
            "$id" = 4e8cf1d6c7e24c063e000000;
        };
        author = faisal;
        comments =         (
                        {
                author = adias;
                comment = amazing;
            },
                        {
                author = nike;
                comment = "I concur";
            }
        );
        created =         {
            sec = 1317772800;
            usec = 0;
        };
        text = "This is a random post";
        title = "post # 1";
        type =         (
            punjabi
        );
    }
)

我如何访问特定元素中的文本键?

我尝试时遇到错误:

[[cell textLabel]setText:[[jokesArray objectAtIndex:[indexPath row]]valueForKey:@"text"]]; 

最佳答案

EXC_BAD_ACCESS 表示您提供了错误的指针。也许您未能正确保留 jokesArray?

关于iphone - 在以下示例中如何从 NSSArray 元素获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7707514/

相关文章:

ios - iPhone 消息应用程序的这个上滑菜单是如何实现的?

objective-c - 在xcode中播放音频

ios - 查找特定 UICollectionView 单元格的索引号

ios - 如何在 shoudPerformSegueWithIdentifier 和 Firebase 中对用户进行身份验证?

iphone - 如何在单击时查看以前的数组值

iphone - 为 iOS 构建 libsox 问题

iphone - 在后台模式下使用 App 接收通知

jquery - iPhone 和 iPad 滚动结束

objective-c - 如何从字典中获取 double 值?

ios - 当通过在警报上滑动将应用程序带到前台时,UILocalNotification 不会停止声音