OLD | NEW |
1 //------------------------------------------------------------------------------
--------- | 1 //------------------------------------------------------------------------------
--------- |
2 // $Id: OCMReturnValueProvider.m 52 2009-08-14 07:21:10Z erik $ | 2 // $Id$ |
3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. | 3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. |
4 //------------------------------------------------------------------------------
--------- | 4 //------------------------------------------------------------------------------
--------- |
5 | 5 |
6 #import "NSMethodSignature+OCMAdditions.h" | 6 #import "NSMethodSignature+OCMAdditions.h" |
7 #import "OCMReturnValueProvider.h" | 7 #import "OCMReturnValueProvider.h" |
8 | 8 |
9 | 9 |
10 @implementation OCMReturnValueProvider | 10 @implementation OCMReturnValueProvider |
11 | 11 |
12 - (id)initWithValue:(id)aValue | 12 - (id)initWithValue:(id)aValue |
13 { | 13 { |
14 » [super init]; | 14 » self = [super init]; |
15 returnValue = [aValue retain]; | 15 returnValue = [aValue retain]; |
16 return self; | 16 return self; |
17 } | 17 } |
18 | 18 |
19 - (void)dealloc | 19 - (void)dealloc |
20 { | 20 { |
21 [returnValue release]; | 21 [returnValue release]; |
22 [super dealloc]; | 22 [super dealloc]; |
23 } | 23 } |
24 | 24 |
25 - (void)handleInvocation:(NSInvocation *)anInvocation | 25 - (void)handleInvocation:(NSInvocation *)anInvocation |
26 { | 26 { |
27 const char *returnType = [[anInvocation methodSignature] methodReturnTyp
eWithoutQualifiers]; | 27 const char *returnType = [[anInvocation methodSignature] methodReturnTyp
eWithoutQualifiers]; |
28 if(strcmp(returnType, @encode(id)) != 0) | 28 if(strcmp(returnType, @encode(id)) != 0) |
29 » » @throw [NSException exceptionWithName:NSInvalidArgumentException
reason:@"Expected invocation with object return type." userInfo:nil]; | 29 » » @throw [NSException exceptionWithName:NSInvalidArgumentException
reason:@"Expected invocation with object return type. Did you mean to use andRe
turnValue: instead?" userInfo:nil]; |
30 [anInvocation setReturnValue:&returnValue]; | 30 [anInvocation setReturnValue:&returnValue]; |
31 } | 31 } |
32 | 32 |
33 @end | 33 @end |
OLD | NEW |