문제

For instance, we have two categories:

@interface NSString (Utilities)
- (void)someMethod;
@end

@interface NSString (RBTree)
- (void)someOtherMethod;
@end

And we need something like this:

if (category that contains someMethod is Utilities){
   // ... anything here ...
}

Just curious.

도움이 되었습니까?

해결책

How curious are you?

Let's start you on a journey:

The Objective C Runtime Reference defines a type Category for categories, but does not itself provide any functions which take or return values of this type. This suggests that some sort of category structure does exist, at least at some point, but the functions that operate on it are not made public.

But why make the type public, if not to reference it somewhere else...?

Dynamic module loading (Dynamic Loading, objc-load.h) provides three functions which take a callback function which is passed an argument of type Category; so more evidence that some structure describing categories exists, at least during loading.

Your next stop might be Apple's open source repository...

Have fun!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top