Created
February 11, 2014 11:52
-
-
Save seivan/8933478 to your computer and use it in GitHub Desktop.
This file contains 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
+(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