Using AFNetworking, I'm able to successfully login without any problems and store a session. As soon as I stop debugging in xcode, the simulator is still open but goes to the iphone homescreen. When I go to run the app again from xcode, the login session is gone and user is nil, spent a couple hours and not sure why. My question is is stop debugging messing with the session of the logged in user? Does using setAuthorizationHeaderWithUsername have to do with anything.
@property (retain, nonatomic) NSDictionary* user;
Login:
[[API sharedInstance] commandWithParams:params
onCompletion:^(NSDictionary *json) {
//handle the response
NSDictionary* res = [[json objectForKey:@"result"] objectAtIndex:0];
if ([json objectForKey:@"error"]==nil && [[res objectForKey:@"IdUser"] intValue]>0) {
//success
[[API sharedInstance] setUser:res];
}
}];
API:
+(API*)sharedInstance
{
static API *sharedInstance = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
sharedInstance = [[self alloc] initWithBaseURL:[NSURL URLWithString:kAPIHost]];
});
return sharedInstance;
}