forwardInvocation을 작동시키는 데 문제가 있습니다. 어떤 이유로 Objective-C 런타임은 forwardInvocation : 메서드를 완전히 무시하고 인식 할 수없는 선택기 예외를 발생시킵니다.forwardInvocation이 호출되지 않습니까?
@interface InvocationTest : NSObject
{
}
+ (void) runTest;
@end
@interface FullClass: NSObject
{
int value;
}
@property(readwrite,assign) int value;
@end
@implementation FullClass
@synthesize value;
@end
@interface SparseClass: NSObject
{
}
@end
@implementation SparseClass
- (void)forwardInvocation:(NSInvocation *)forwardedInvocation
{
NSLog(@"ForawrdInvocation called");
FullClass* proxy = [[[FullClass alloc] init] autorelease];
proxy.value = 42;
[forwardedInvocation invokeWithTarget:proxy];
}
@end
@implementation InvocationTest
+ (void) runTest
{
SparseClass* sparse = [[[SparseClass alloc] init] autorelease];
NSLog(@"Value = %d", [sparse value]);
}
@end
을 나는 다음과 같은 자원의 정보를 일하고 있어요 : 내가 말할 수있는
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html#//apple_ref/doc/uid/TP40008048-CH105 http://cocoawithlove.com/2008/03/construct-nsinvocation-for-any-message.html
이는 지금까지, 런타임해야 다음과 같이
내 테스트 코드는 forwardInvocation을 호출하는 중 : [희소 가치]를 호출 할 때 SparseClass의 인스턴스에서 호출되지만 완전히 무시됩니다.
,451,515,'인식 선택기 인스턴스 0x4b1c4a0 전송 [SparseClass 값]'인식 선택기 인해 캐치되지 않는 예외 'NSInvalidArgumentException'이유 응용 프로그램 종료 *** 인스턴스 0x4b1c4a0 보내는 - [SparseClass 값] - :
굉장! 매력처럼 일했습니다. – Karl