“Unable to restore previously selected frame” when looping through NSDictionary

自作多情 提交于 2019-12-11 06:25:05

问题


I got the following errors in my app:

warning:Unable to restore previously selected frame
warning:Unable to restore previously selected frame

when using the following code:

NSDictionary *feed = [json_parser objectWithString:json_str error:nil];
for(NSDictionary *feed_item in [feed objectForKey:@"items"])
{
    PropertyData *propertyData; // mere data model class with properties only,no methods
    [propertyData release];
}

with this line hightlighted Thread 1: Program received signal: "EXC_BAD_ACCESS"

[propertyData release];

the json string looks like the following before parsing (so you may understand how data are structured, the parsing works fine though):

{
    "total":110,"page":1,
    "items":[
        {"pid":"1349","price":"52,000","type":"Apartment","beds":"","descr1":"<p></p>"},
        {"pid":"1349","price":"52,000","type":"Apartment","beds":"","descr1":"<p></p>"},
        {"pid":"1349","price":"52,000","type":"Apartment","beds":"","descr1":"<p></p>"}
    ]
}

Any idea of what's wrong ?

Thx for helping,

Stephane


回答1:


You are not allocating/initializing PropertyData. The pointer is referring to some random place in memory, and then you are sending it "release" message which causes the EXC_BAD_ACCESS,



来源:https://stackoverflow.com/questions/7385685/unable-to-restore-previously-selected-frame-when-looping-through-nsdictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!