1

我正在使用 TouchJson 解析来自 facebooks graph api 的 json 数据。虽然我遇到了一些内存泄漏,但我真的不明白为什么......

在我努力寻找泄漏的过程中,我已经删除了其他所有内容,所以下面的代码就是我留下的。泄漏是每个循环的一个 NSCFString,我知道它来自对 myItem.date 的分配,但我不明白为什么?

我正在使用最新版本的 TouchJson

NSError *error;
NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:data error:&error];
NSArray *jsonArray = [jsonDictionary objectForKey:@"data"];

for (NSDictionary *jsonEntry in jsonArray) {
    NSDictionary *fromDictionary = [jsonEntry objectForKey:@"from"];
    NSString *userId = [fromDictionary objectForKey:@"id"];

    // Continue if it is a post from Atlas
    if (userId != nil && [userId isEqualToString:@"10465958627"]){
        MyItem *myItem = [[MyItem alloc] init];

        // This uncommented causes the leak, why?
        myItem.date = [jsonEntry objectForKey:@"created_time"];

        [myItem release];
    }
}

谢谢您的帮助!

编辑:我忘了提到 MyItem 只是一个具有这样属性的对象

@property (nonatomic, copy) NSString *date;
4

0 回答 0