其实有两个错误,第一个是: “函数“class_getname”的隐式声明在 c99 中无效”
第二个是: 不兼容的整数到指针转换使用类型为“int”的表达式初始化“const char *”
我的方法是:
-(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];
....
}
关于如何解决这个问题的任何帮助?谢谢
最佳答案
您需要 #import <objc/runtime.h>
关于objective-c - IOS & Objective C - 我如何解决这个错误 "implicit declaration of function "class_getname "is invalid in c99"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30025593/