Encoding issue: Cocoa Error 261?

后端 未结 5 781
耶瑟儿~
耶瑟儿~ 2021-02-12 14:01

So I\'m fetching a JSON string from a php script in my iPhone app using:

NSURL *baseURL = [NSURL URLWithString:@\"test.php\"];
NSError *encodeError = [[NSError a         


        
5条回答
  •  不要未来只要你来
    2021-02-12 14:59

    Encoding issue: Cocoa Error 261? I solved this issue by trying different encoding. First I was using NSUTF8 then I switched to NSASCIIStringEncoding and it worked.

    NSString* path = [[NSBundle mainBundle] pathForResource: @"fileName" ofType: @"type"];
    NSData* data = [NSData dataWithContentsOfFile:path];
    NSString *string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
    NSLog(@"%@",string);
    

提交回复
热议问题