1

Im facing memory leaks in many cases when I try to parse JSON. Thought its telling SBJsonParser , I know that wont be a cause.

- (id)JSONValue {
    SBJsonParser *jsonParser = [SBJsonParser new];
    id repr = [jsonParser objectWithString:self]; // 100.0 % Memory Leak
    if (!repr)
        NSLog(@"-JSONValue failed. Error is: %@", jsonParser.error);
    [jsonParser release];
    return repr;
}

and also memory leak happening at

"id result=[JSON valueForKeyPath:@"result"]; " 
// 100.0% memory leak
id repr = [jsonParser objectWithString:self]; // 80.0% Memory Leak

What I need to do to fix this > :( Thanks.

4

1 回答 1

0

你应该改用这个:

NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:receivedData options:NSJSONReadingMutableContainers error:nil];
于 2013-07-04T16:40:48.863 回答