Created
February 15, 2012 22:20
-
-
Save aaronpearce/1839441 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0ul), ^{ | |
// Do a taks in the background | |
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | |
[[storage cookies] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
[storage deleteCookie:obj]; | |
if(stop) { | |
NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData:[[self.array objectAtIndex:indexPath.row] objectAtIndex:1]]; | |
[cookies enumerateObjectsUsingBlock:^(id obj2, NSUInteger idx, BOOL *stop2) { | |
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:obj2]; | |
if(stop2) { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[[NSNotificationCenter defaultCenter] postNotificationName:@"getFolders" object:nil]; | |
[[NSUserDefaults standardUserDefaults] setValue:[[self.array objectAtIndex:indexPath.row] objectAtIndex:0] forKey:@"currentUser"]; | |
[[NSUserDefaults standardUserDefaults] synchronize]; | |
[SVProgressHUD dismissWithSuccess:@"Switched!"]; | |
[self closeView]; | |
}); | |
} | |
}]; | |
} | |
}]; | |
// Hide the HUD in the main tread | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment