What is the best solution to avoid bad access in this kind of situations ?
__block NSString* string;
dispatch_sync(dispatch_get_main_queue(), ^{
string = [NSString stringWithString:@"I'm autoreleased!"];
});
NSLog(@"My string is: %@", string);
I changed my code to this:
NSMutableString *string = [[NSMutableString alloc] init];
dispatch_sync(dispatch_get_main_queue(), ^{
[string appendString:@"I'm autoreleased!"];
});
NSLog(@"My string is: %@", string);
[string release];
but I was wondering if there no better solutions