개체가 NSNotification인지 확인해야합니다. NSNotification인지 또는 NSNotification의 하위 클래스인지 구분할 때 하위 클래스인지 여부는 알기에 충분하지 않습니다. 그래서 테스트 유형 NSNotification
나는 다음과 같은 구별 할 필요가 정교 :문제는 NSNotifications가 있다는 것입니다
- NSConcreteNotification
- NSNotification의 서브 클래스 (그러나 NSConcreteNotification) 실제로 NSConcreteNotifications 및 NSConcreteNotification은 개인 클래스이므로 테스트 할 때 사용할 수 없습니다. 필요에 따라이
NSConcreteNotifications
사용[object isMemberOfClass:NSClassFromString(@"NSConcreteNotifications")];
변경 다른 클래스의 이름을 문자열 인 경우
[object isMemberOfClass:[NSNotification class]];`
테스트 : ID 객체를 테스트하려면
[object isMemberOfClass: [NSNotification class]] // returns NO in both cases [object isKindOfClass: [NSNotification class]] // returns YES in both cases
테스트 대상은 NSNotification no의 하위 클래스입니까? – Geoffroy
objective-C의 isMemberOfClass 메소드를 사용할 수 있습니다. 참조하시기 바랍니다 [isMemberOfClass] [1] [1] : http://stackoverflow.com/questions/2045561/objective-c-iskindofclass-missunderstanding – Naved
1. NSConcreteNotification 또는 2.이 될 수있는 객체 NSNotification의 서브 클래스. 나는 그 차이를 말할 필요가있다. – Undistraction