How can I use class_getProperty in iPad? (Not a simulator)

I use class_getProperty()in my application for iPad. I tried #import <objc/objc-runtime.h>that works on an iPad simulator.

But when I try to run it on my iPad, Xcode says:

objc / objc-runtime.h: No such file or directory

and

warning: implicit declaration of function 'class_getProperty'.

+3
source share
1 answer

Please note that there are differences between the simulator and the device. The simulator does not start the same SDK as the device. The lower layers from the Mac SDK are actually what makes sense since it runs on a Mac.

, , . , Jeff Lamarche : Simulator

#import <objc/objc-runtime.h>

#import <objc/runtime.h>
#import <objc/message.h>

, , :

#if (TARGET_OS_IPHONE)
- (NSString *)className;
+ (NSString *)className;
#endif

:

#if (TARGET_OS_IPHONE)
- (NSString *)className {
 return [NSString stringWithUTF8String:class_getName([self class])];
}
+ (NSString *)className {
 return [NSString stringWithUTF8String:class_getName(self)];
}
#endif
+8

Source: https://habr.com/ru/post/1753846/


All Articles