1

因此,我从 Web 服务加载了我的自定义对象,并尝试将属性存储为 NSStrings,但一直遇到此错误:

-[CFString _cfTypeID]: message sent to deallocated instance 0x100d3d40
-[CFString retain]: message sent to deallocated instance 0x100d3d40

我启用了僵尸,但这并没有真正向我展示解决方案。

我的属性定义为:

@property (strong, nonatomic) NSString *title;
@property (assign, nonatomic) NSString *ID;
@property (strong, nonatomic) NSString *redLabel;
@property (strong, nonatomic) NSString *greenLabel;

然后我创建我的对象的一个​​实例并调用 web 服务

QuickList *list = [[QuickList alloc] init];
[list loadLatestQuickList];

最后,在里面loadLatestQuickList...

NSURLRequest *request = // create a GET request...
[NSURLConnection sendAsynchronousRequest:request queue:notMainQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
    NSError *parsingError;
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parsingError];
    if (!parsingError && [json isKindOfClass:[NSDictionary class]]) {
        NSDictionary *dataDictionary = [json objectForKey:@"data"];
        NSDictionary *quickListDictionary = [dataDictionary objectForKey:@"QuickList"];

        NSString *ID = [quickListDictionary objectForKey:@"id"];
        NSString *title = [quickListDictionary objectForKey:@"name"];
        NSString *redLabel = [quickListDictionary objectForKey:@"red_label"];
        NSString *greenLabel = [quickListDictionary objectForKey:@"green_label"];

        self.ID = ID;
        self.title = title;
        self.redLabel = redLabel;
        self.greenLabel = greenLabel;

        // tell a channel that everything is loaded
    }
    else {
        NSLog(@"%@",parsingError);
    }
}];

现在,每当我尝试访问list.ID或其他一些属性时,我都会收到“deallocated instance”错误。关于我为什么会收到此错误的任何想法?

4

1 回答 1

3

你的ID财产也应该如此strong

于 2012-07-21T17:36:49.127 回答