Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stringWithContentsOfFile Deprecated

Tags:

nsstring

I use the following code in my app, but it gives a 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];
like image 204
Vijay Avatar asked Sep 06 '11 08:09

Vijay


1 Answers

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.

like image 132
xci Avatar answered Feb 16 '23 22:02

xci