-1
您好我正在研究iOS中的簡單激活應用程序。我想保存的UDID在文本文件中,平等的文本文件與當前的UDID,但我不能保存UDID到文本文件將udid字符串保存到文本文件
NSString *udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"h" ofType:@"txt"]];
NSMutableString *text = [NSMutableString stringWithContentsOfURL:fileURL encoding:NSUTF8StringEncoding error:nil];
NSLog(@"text is : %@",text);
NSString *text1 = text;
NSString *y;
if ([text1 isEqualToString:y]) {
[text appendString:udid];
NSString *myURLString = [fileURL absoluteString];
[text writeToFile:myURLString atomically: YES encoding:NSUTF8StringEncoding error:nil];
NSLog(@"saved to file : %@",text);
}else {
if ([text isEqualToString:udid]) {
NSLog(@"yes thats it");
lable.text = @"yes thats it";
}else {
NSLog(@"nononono");
exit(0);
}
}
它給我:寫入文件時出錯:///Users/mji/Library/Application%20Support/iPhone%20Simulator/7.0-64/Applications/C48463FB-F7F0-47AD-A40A-958A3583C29E/active%20text。 app/h.txt是操作無法完成。 (可可錯誤4.) – user3001228
你不應該試圖寫入應用程序的包,這是不允許的。 –
現在它給了我這個當我想保存udid文件寫入文件錯誤:///Users/mji/Library/Application%20Support/iPhone%20Simulator/7.0-64/Applications/C48463FB-F7F0-47AD-A40A -958A3583C29E/Documents/h.txt爲(null) – user3001228