Skip to content

Instantly share code, notes, and snippets.

@seivan
Created February 11, 2014 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seivan/8933478 to your computer and use it in GitHub Desktop.
Save seivan/8933478 to your computer and use it in GitHub Desktop.
+(instancetype)me; {
XXXCurrentUser * me = [XXXCurrentUser MR_findFirst];
[XXXClient sharedManager].accessCredential = [[LUKeychainAccess standardKeychainAccess]
objectForKey:NSStringFromClass([self class])];
if(me == nil || [XXXClient sharedManager].accessCredential == nil) {
me = nil;
[self logout];
}
return me;
}
+(void)logout; {
[[LUKeychainAccess standardKeychainAccess] setObject:nil forKey:NSStringFromClass([self class])];
[XXXCurrentUser MR_truncateAll]; //This is using cascading to get rid of any other record in the DB.
[[MagicalRecordStack defaultStack].context MR_saveToPersistentStoreAndWait];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment