Objective c 从JSON加载属性,获取;已发送到解除分配实例的消息“;
因此,我从web服务加载我的自定义对象,并尝试将属性存储为NSStrings,但始终遇到以下错误:Objective c 从JSON加载属性,获取;已发送到解除分配实例的消息“;,objective-c,ios,automatic-ref-counting,Objective C,Ios,Automatic Ref Counting,因此,我从web服务加载我的自定义对象,并尝试将属性存储为NSStrings,但始终遇到以下错误: -[CFString _cfTypeID]: message sent to deallocated instance 0x100d3d40 -[CFString retain]: message sent to deallocated instance 0x100d3d40 我启用了僵尸,但这并没有真正向我展示解决方案 我的财产定义如下: @property (strong, nonatomi
-[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;
然后我创建一个对象的实例并调用webservice
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”错误。关于我为什么会出现此错误,您有什么想法吗?您的ID
属性也应该是strong