Using __unsage_unretained for getting invocation arguments.

This commit is contained in:
Oliver Letterer 2013-05-22 21:44:42 +02:00
parent 380f0c16aa
commit b6769ee794
2 changed files with 13 additions and 4 deletions

View file

@ -271,7 +271,10 @@
__block NSArray *operations = nil; __block NSArray *operations = nil;
id mockClient = [OCMockObject partialMockForObject:self.client]; id mockClient = [OCMockObject partialMockForObject:self.client];
void (^theBlock)(NSInvocation *) = ^(NSInvocation *invocation) { void (^theBlock)(NSInvocation *) = ^(NSInvocation *invocation) {
[invocation getArgument:&operations atIndex:2]; __unsafe_unretained id argument = nil;
[invocation getArgument:&argument atIndex:2];
operations = argument;
}; };
[[[mockClient stub] andDo:theBlock] enqueueBatchOfHTTPRequestOperations:[OCMArg any] progressBlock:nil completionBlock:nil]; [[[mockClient stub] andDo:theBlock] enqueueBatchOfHTTPRequestOperations:[OCMArg any] progressBlock:nil completionBlock:nil];
[mockClient enqueueBatchOfHTTPRequestOperationsWithRequests:@[ firstRequest, secondRequest ] progressBlock:nil completionBlock:nil]; [mockClient enqueueBatchOfHTTPRequestOperationsWithRequests:@[ firstRequest, secondRequest ] progressBlock:nil completionBlock:nil];
@ -294,12 +297,18 @@
__block NSArray *operations = nil; __block NSArray *operations = nil;
[[[mockOperationQueue stub] andDo:^(NSInvocation *invocation) { [[[mockOperationQueue stub] andDo:^(NSInvocation *invocation) {
[invocation getArgument:&operations atIndex:2]; __unsafe_unretained id argument = nil;
[invocation getArgument:&argument atIndex:2];
operations = argument;
}] addOperations:OCMOCK_ANY waitUntilFinished:NO]; }] addOperations:OCMOCK_ANY waitUntilFinished:NO];
__block NSBlockOperation *batchedOperation = nil; __block NSBlockOperation *batchedOperation = nil;
[[[mockOperationQueue stub] andDo:^(NSInvocation *invocation) { [[[mockOperationQueue stub] andDo:^(NSInvocation *invocation) {
[invocation getArgument:&batchedOperation atIndex:2]; __unsafe_unretained id argument = nil;
[invocation getArgument:&argument atIndex:2];
batchedOperation = argument;
}] addOperation:OCMOCK_ANY]; }] addOperation:OCMOCK_ANY];
[mockClient enqueueBatchOfHTTPRequestOperations:@[ firstOperation, secondOperation ] progressBlock:NULL completionBlock:NULL]; [mockClient enqueueBatchOfHTTPRequestOperations:@[ firstOperation, secondOperation ] progressBlock:NULL completionBlock:NULL];

View file

@ -17,7 +17,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFHTTPRequestOperationLogger: 34ba125cb9eeb77a3b67aaaca105720ba3a0798c AFHTTPRequestOperationLogger: 34ba125cb9eeb77a3b67aaaca105720ba3a0798c
AFNetworking: 02a1b682b3c3fa39afd22e725ab8f4a65cb157b6 AFNetworking: d1ba5908b233189e424e101721acef7905b58efb
Expecta: d46fb1bd78c90a83da0158b9b1e108de106e369f Expecta: d46fb1bd78c90a83da0158b9b1e108de106e369f
OCMock: 79212e5e328378af5cfd6edb5feacfd6c49cd8a3 OCMock: 79212e5e328378af5cfd6edb5feacfd6c49cd8a3