I get this warning in Xcode
warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
Xcode redirect me to my NSStream
_naturStream = [[NSInputStream alloc] initWithData:natur];
It is random when it does this error, and my application crashes when it is triggered. Anyone tried similar problem ?
thanks
EDIT
in the appDelegate.h
@property (nonatomic, strong) NSInputStream *naturStream;
In the appDelegate.m:
NSData *natur = [NSData dataWithContentsOfURL:[NSURL URLWithString:_locString]];
_naturStream = [[NSInputStream alloc] initWithData:natur];
[_naturStream open];
if (_naturStream) {
NSError *parseError = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithStream:_naturStream options:NSJSONReadingAllowFragments error:&parseError];
if ([jsonObject respondsToSelector:@selector(objectForKey:)]) {
for (NSDictionary *natur in [jsonObject objectForKey:@"results"]) {
_poi = [[POI alloc]init];
[_poi setTitle:[natur objectForKey:@"title"]];
[_poi setLat:[[natur objectForKey:@"lat"]floatValue]];
[_poi setLon:[[natur objectForKey:@"lng"]floatValue]];
[_poi setDistance:[natur objectForKey:@"distance"]];
[_poi setWebUrl:[natur objectForKey:@"webpage"]];
[_naturArray addObject:_poi];
}
}
}
else {
NSLog(@"Failed to open stream.");
}
[_naturStream close];
}
I realized that i forgot [_naturStream close]
i don't know if it has solved the problem or not ?
EDIT
Another thing,.... I use a Thread for fetching the JSON data:
dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);
// execute a task on that queue asynchronously
dispatch_async(jsonParsingQueue, ^{
[self parseJSON];
dispatch_async(dispatch_get_main_queue(), ^{
[_kortvisning updateAnno];
[visListe updateList];
});
});
// release the dispatch queue
dispatch_release(jsonParsingQueue);