“Unable to restore previously selected frame” when

2019-08-04 18:23发布

问题:

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,