0
간단한 웹 사이트 데이터를 파일로 저장하는 데 문제가 있습니다. 나는 sintax가 정확하다고 누군가가 나를 도울 수 있다고 믿는가? 내가 그것을 실행할 때, 그것은 데이터를 가져 오는 것을 보여 주지만, 내가 끝내고 저장할 파일을 열면 아무 것도 없다.파일에 NSString 저장
- (BOOL)textFieldShouldReturn:(UITextField *)nextField {
[timer invalidate];
startButton.hidden = NO;
startButton.enabled = YES;
stopButton.enabled = NO;
stopButton.hidden = YES;
stopLabel.hidden = YES;
label.hidden = NO;
label.text = @"Press to Activate";
[nextField resignFirstResponder];
NSString *urlString = textField.text;
NSData *dataNew = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
NSUInteger len = [dataNew length];
NSString *stringCompare = [NSString stringWithFormat:@"%i", len];
NSLog(@"%@", stringCompare);
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"websiteone" ofType:@"txt"];
if (filePath) {
[stringCompare writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:NULL];
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
NSLog(@"Saving... %@", myText);
}
else {
NSLog(@"cant find the file");
}
return YES;
}