here is my code:
+ (instancetype)sharedInstance
{
static PanoramaDataManager *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[PanoramaDataManager alloc] init];
[NSURLConnection sendAsynchronousRequest:[sharedInstance requestToService:kPanoramaAPIGetToken withParams:@{@"login" : kPanoramaAPILogin, @"password" : kPanoramaAPIPassword}] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (!connectionError) {
NSError *error;
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data
options:kNilOptions
error:&error];
if (!error) {
sharedInstance.token = [jsonResponse objectForKey:@"token"];
} else {
[BxAlertView showError:error.description];
}
} else {
[BxAlertView showError:connectionError.description];
}
}];
});
return [sharedInstance autorelease];
}
All i want to do is just to send the request to the server to receive the token for all the rest requests during the singleton initialisation. But I have an exception of bad access in the line where I try to set the property. If I try to write NSError *error = nil;
the app is stopped with the exception of bad access. Any help?