mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-30 13:42:35 +08:00
Fix a few issues identified via static analysis
This commit is contained in:
@@ -54,7 +54,11 @@ static RKManagedObjectStore *defaultStore = nil;
|
|||||||
|
|
||||||
+ (void)setDefaultStore:(RKManagedObjectStore *)managedObjectStore
|
+ (void)setDefaultStore:(RKManagedObjectStore *)managedObjectStore
|
||||||
{
|
{
|
||||||
@synchronized(defaultStore) {
|
if (defaultStore) {
|
||||||
|
@synchronized(defaultStore) {
|
||||||
|
defaultStore = managedObjectStore;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
defaultStore = managedObjectStore;
|
defaultStore = managedObjectStore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,7 +324,7 @@ static RKManagedObjectStore *defaultStore = nil;
|
|||||||
// We can only do migrations within a versioned momd
|
// We can only do migrations within a versioned momd
|
||||||
if (![[momdURL pathExtension] isEqualToString:@"momd"]) {
|
if (![[momdURL pathExtension] isEqualToString:@"momd"]) {
|
||||||
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Migrations can only be performed to versioned destination models contained in a .momd package. Incompatible destination model given at path '%@'", [momdURL path]];
|
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Migrations can only be performed to versioned destination models contained in a .momd package. Incompatible destination model given at path '%@'", [momdURL path]];
|
||||||
*error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
|
if (error) *error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +353,7 @@ static RKManagedObjectStore *defaultStore = nil;
|
|||||||
// Cannot complete the migration as we can't find a source model
|
// Cannot complete the migration as we can't find a source model
|
||||||
if (! sourceModel) {
|
if (! sourceModel) {
|
||||||
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Unable to find the source managed object model used to create the %@ store at path '%@'", storeType, [storeURL path]];
|
NSString *errorDescription = [NSString stringWithFormat:@"Migration failed: Unable to find the source managed object model used to create the %@ store at path '%@'", storeType, [storeURL path]];
|
||||||
*error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationMissingSourceModelError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
|
if (error) *error = [NSError errorWithDomain:RKErrorDomain code:NSMigrationMissingSourceModelError userInfo:@{ NSLocalizedDescriptionKey: errorDescription }];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,8 +366,11 @@ static RKManagedObjectStore *defaultStore = nil;
|
|||||||
RKLogError(@"%@", *error);
|
RKLogError(@"%@", *error);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *UUID = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(NULL));
|
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
|
||||||
|
NSString *UUID = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, uuid);
|
||||||
|
CFRelease(uuid);
|
||||||
|
|
||||||
NSString *migrationPath = [NSTemporaryDirectory() stringByAppendingFormat:@"Migration-%@.sqlite", UUID];
|
NSString *migrationPath = [NSTemporaryDirectory() stringByAppendingFormat:@"Migration-%@.sqlite", UUID];
|
||||||
NSURL *migrationURL = [NSURL fileURLWithPath:migrationPath];
|
NSURL *migrationURL = [NSURL fileURLWithPath:migrationPath];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user