IOS&目标C - 如何解决此错误“隐式声明函数”class_getname"在c99中无效?“

IOS&目标C  - 如何解决此错误“隐式声明函数”class_getname"在c99中无效?“

问题描述:

实际上有两个错误,第一个是:
隐含的函数声明class_getname在c99中无效

Actually there are two errors, the first one is : "implicit declaration of function "class_getname " is invalid in c99"

第二个是:
与指针转换不兼容的整数使用类型'int'的表达式初始化'const char *'

The second one is : incompatible integer to pointer conversion initializing 'const char*' with an expression of type 'int'

我的方法是:

-(void) donneesrecoltees:(NSData *)donnees {
    NSError *erreur;
    NSNumber *lastMessage,*currentMessage;


    //int i;
    NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
    NSString *msg;

    UIAlertView *alert;

    NSDictionary *json=[NSJSONSerialization JSONObjectWithData:donnees options:0 error:&erreur];
    // Check if it's the right class to avoid error stack

    // this is the line that is causing the error
    const char* className = class_getName([json class]);

    NSString *myClass=[NSString stringWithFormat:@"%s",className];

....

}

有关如何解决此问题的任何帮助?谢谢

Any help on how to fix this? thank you

你需要 #import< objc / runtime.h>