카테고리 없음

sender가 올바른 class인지 확인

KraZYeom 2012. 10. 28. 02:37
반응형

NSAssert를 사용하여 


#define NSAssert(condition, desc, ...) \

    do { \

__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \

if (!(condition)) { \

    [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \

object:self file:[NSString stringWithUTF8String:__FILE__] \

    lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \

} \

        __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \

    } while(0)

#endif


-(void) method:(id)sender

{

    // Make sure sender is actually of the right class.

    NSAssert([sender isKindOfClass:[MyClass class]], @"sender is not a MyClass!");

MyClass* myClass = (MyClass*)sender;


}




코드가 곧 설명


반응형