Je viens d'essayer le segment de code suivant et im ayant une erreur: -objectif étrange erreur c en utilisant base64
#import "JSONKit.h"
#import "Base64.h"
#import <Foundation/Foundation.h>
int main() {
NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:(id)@"value" forKey:(id)@"key"];
for(id key in dict) NSLog(@"%@\t%@\n", key, [dict objectForKey:key]);
[Base64 initialize];
NSData *jsonstr = [dict JSONStringWithOptions:JKSerializeOptionNone error:nil];
NSString *val = [Base64 encode: jsonstr];
NSLog(@"%@\n", val);
return 0;
}
L'erreur que je suis arrivé est: -
test.m: In function ‘main’:
test.m:13: warning: incompatible Objective-C types initializing ‘struct NSString *’, expected ‘struct NSData *’
Undefined symbols:
"_OBJC_CLASS_$_Base64", referenced from:
[email protected] in cc23xlpr.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Afin de supprimer l'avertissement, je changé une ligne à: -
NSData *jsonstr = (NSData *)[dict JSONStringWithOptions:JKSerializeOptionNone error:nil];
Cependant, l'erreur reste - être de nouveau à objective-C je trouve l'erreur tout à fait crypti c, quelqu'un pourrait-il m'aider à comprendre la source du problème/une solution à la même chose?
Merci pour votre réponse - mais maintenant j'obtiens une erreur légèrement différente => https://gist.github.com/56381c2e6dd7c18d7501 –