Manos Chorianopoulos

possible fix for initialize crash

......@@ -241,12 +241,29 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError *
[self createDBIfNeeded];
[self initDBIfNeeded];
[self restore];
// [self restore];
@try {
[self restore];
}
@catch (NSException *exception) {
NSLog(@"restore error: %@", exception.reason);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.appUUID = [defaults stringForKey:@"NBAPPUuidUD"];
self.apiKey = [defaults stringForKey:@"NBAPIKeyUD"];
self.webId = [defaults stringForKey:@"NBWebIDUD"];
}
@finally {
// NSLog(@"Finally condition");
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([_appUUID isEqualToString:appUUID] == NO) {
self.appUUID = appUUID;
self.apiKey = nil;
self.webId = nil;
[defaults setObject:appUUID forKey:@"NBAPPUuidUD"];
[defaults setBool:YES forKey:@"NBAPPUuidChanged"];
}
else [defaults setBool:NO forKey:@"NBAPPUuidChanged"];
......@@ -5677,6 +5694,11 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
self.apiKey = [context valueForKey:@"api_key"];
self.webId = [context valueForKey:@"web_id"];
[WLKeychain setString:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forKey:@"old_identifier_for_vendor"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[context valueForKey:@"api_key"] forKey:@"NBAPIKeyUD"];
[defaults setObject:[context valueForKey:@"web_id"] forKey:@"NBWebIDUD"];
[[NSUserDefaults standardUserDefaults] synchronize];
[_pendingOperationsQueue setSuspended:![self isRegistrationValid]];
if (success) {
......