2012-02-03 2 views
3

login.txt라는 파일에 대한 사용자 이름 인 textField 값을 쓰고 싶습니다.WriteToFile : atomically deprecate 경고

내 코드 : 나는 "원자 : wrtieToFile"이라고 경고 얻을

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 

// the path to write file 
loginFilePath= [documentsDirectory stringByAppendingPathComponent:@"Login.txt"]; 
NSString *userName=[nameText text]; 
[userName writeToFile:loginFilePath atomically:YES]; 

이되지 않습니다. 이 사용되지 않기 때문에

+0

[여기] (https://developer.apple.com/library/IOs/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/DeprecationAppendix/AppendixADeprecatedAPI.html)를보십시오. –

답변

4

는 사용

- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile encoding:(NSStringEncoding)enc error:(NSError **)error; 

대신 문서

Writes the contents of the receiver to the file specified by a given path. (Deprecated in iOS 2.0. Use writeToFile:atomically:encoding:error: instead.)

The NSString documentation states that it's deprecated

0

writeToFile:atomically의 방법 writeToFile:atomically:encoding:error:here을 찾을 수있는 교체.

0

iOS 11 writeToFile:atomically 현재 - writeToUrl:error:을 사용하고 있습니다.

이전 쓰기/읽기 메소드가 많이 사용되지 않아 NSArray에 대한 지원이 중단되었으며 API가 단순화 된 것처럼 보입니다. 따라서 파일에서 NSArray을 만들면 - initWithContentsOfURL:error:이 사용됩니다.