2
0

Fixed importing with a different key and entity access after MOC changes.

[FIXED]   Importing stored content when not logged in with the same key.
[FIXED]   Holding entities is a bad idea when MOCs can change.  Holding ObjectIDs instead now.
This commit is contained in:
Maarten Billemont
2012-08-18 15:37:24 +02:00
parent d429044f64
commit 479d357bd1
5 changed files with 26 additions and 11 deletions

View File

@@ -7,12 +7,16 @@
//
#import "MPAppDelegate_Shared.h"
#import "MPAppDelegate_Store.h"
@interface MPAppDelegate_Shared ()
@property (strong) NSManagedObjectID *activeUserID;
@end
@implementation MPAppDelegate_Shared
@synthesize key;
@synthesize activeUser;
+ (MPAppDelegate_Shared *)get {
#if TARGET_OS_IPHONE
@@ -41,4 +45,14 @@
#endif
}
- (MPUserEntity *)activeUser {
return (MPUserEntity *)[self.managedObjectContextIfReady objectWithID:self.activeUserID];
}
- (void)setActiveUser:(MPUserEntity *)activeUser {
self.activeUserID = activeUser.objectID;
}
@end

View File

@@ -185,6 +185,7 @@
if (!key)
return;
assert([key.keyID isEqualToData:self.user.keyID]);
[self setContent:content usingKey:key];
}
@@ -209,7 +210,7 @@
- (void)setContent:(id)content usingKey:(MPKey *)key {
assert(self.type & MPElementTypeClassStored);
assert([key.keyID isEqualToData:self.user.keyID]);
assert(key);
NSData *encryptedContent = [[content description] encryptWithSymmetricKey:[key subKeyOfLength:PearlCryptKeySize].keyData padding:YES];