开发者

stringWithContentsOfFile Deprecated

开发者 https://www.devze.com 2023-04-03 01:56 出处:网络
I use the following code in my app, but it gives a开发者_JAVA百科 warning that stringWithContentsOfFile is deprecated.

I use the following code in my app, but it gives a开发者_JAVA百科 warning that stringWithContentsOfFile is deprecated.

Can anyone tell me how to avoid this warning? Will this warning affect my app in the future?

NSString *myData= [NSString stringWithContentsOfFile:path];


Thought I might expand on daveoncode's answer a bit, so if you are not interested in the errors, you can just simply write

NSString *myData= [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

and it will work as you expected.


You have to use stringWithContentsOfFile:encoding:error: or stringWithContentsOfFile:usedEncoding:error:

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号