IOS & Objective C - how can i resolve this error “implicit declaration of function ”class_getname “ is invalid in c99”?

笑着哭i 提交于 2019-12-06 13:51:48

问题


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

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

my method is :

-(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


回答1:


You need to #import <objc/runtime.h>



来源:https://stackoverflow.com/questions/30025593/ios-objective-c-how-can-i-resolve-this-error-implicit-declaration-of-functi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!