samouray
samouray

Reputation: 578

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

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

Upvotes: 2

Views: 7277

Answers (1)

Fjölnir
Fjölnir

Reputation: 490

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

Upvotes: 9

Related Questions