mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Port passing Logic Test coverage to ARC
This commit is contained in:
@@ -154,28 +154,27 @@
|
||||
|
||||
- (void)createBackgroundObjects
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
assertThatBool([NSThread isMainThread], equalToBool(NO));
|
||||
@autoreleasepool {
|
||||
assertThatBool([NSThread isMainThread], equalToBool(NO));
|
||||
|
||||
// Assert this is not the main thread
|
||||
// Create a new array of objects in the background
|
||||
RKObjectManager *objectManager = [RKTestFactory objectManager];
|
||||
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];
|
||||
objectManager.managedObjectStore = managedObjectStore;
|
||||
NSArray *humans = [NSArray arrayWithObject:[NSEntityDescription entityForName:@"RKHuman" inManagedObjectContext:managedObjectStore.primaryManagedObjectContext]];
|
||||
_dictionary = [[NSMutableDictionary dictionaryWithObject:humans forKey:@"humans"] retain];
|
||||
NSMethodSignature *signature = [self methodSignatureForSelector:@selector(informDelegateWithDictionary:)];
|
||||
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
|
||||
invocation.privateQueueManagedObjectContext = _objectStore.primaryManagedObjectContext;
|
||||
invocation.mainQueueManagedObjectContext = _objectStore.mainQueueManagedObjectContext;
|
||||
[invocation retain];
|
||||
[invocation setTarget:self];
|
||||
[invocation setSelector:@selector(informDelegateWithDictionary:)];
|
||||
[invocation setArgument:&_dictionary atIndex:2]; // NOTE: _cmd and self are 0 and 1
|
||||
[invocation setManagedObjectKeyPaths:[NSSet setWithObject:@"humans"] forArgument:2];
|
||||
[invocation invokeOnMainThread];
|
||||
// Assert this is not the main thread
|
||||
// Create a new array of objects in the background
|
||||
RKObjectManager *objectManager = [RKTestFactory objectManager];
|
||||
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];
|
||||
objectManager.managedObjectStore = managedObjectStore;
|
||||
NSArray *humans = [NSArray arrayWithObject:[NSEntityDescription entityForName:@"RKHuman" inManagedObjectContext:managedObjectStore.primaryManagedObjectContext]];
|
||||
_dictionary = [NSMutableDictionary dictionaryWithObject:humans forKey:@"humans"];
|
||||
NSMethodSignature *signature = [self methodSignatureForSelector:@selector(informDelegateWithDictionary:)];
|
||||
RKManagedObjectThreadSafeInvocation *invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
|
||||
invocation.privateQueueManagedObjectContext = _objectStore.primaryManagedObjectContext;
|
||||
invocation.mainQueueManagedObjectContext = _objectStore.mainQueueManagedObjectContext;
|
||||
[invocation setTarget:self];
|
||||
[invocation setSelector:@selector(informDelegateWithDictionary:)];
|
||||
[invocation setArgument:&_dictionary atIndex:2]; // NOTE: _cmd and self are 0 and 1
|
||||
[invocation setManagedObjectKeyPaths:[NSSet setWithObject:@"humans"] forArgument:2];
|
||||
[invocation invokeOnMainThread];
|
||||
|
||||
[pool drain];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user