ProAnswers.org

In Xcode 3.2.6, What does the error "'stringWithContentsOfFile:' is deprecated" mean? Can it be solved?

Now that I’ve started working with the latest and greatest iPhone SDK I’m running into a bunch of deprecated method errors. It’s recommended practice to treat warnings the same as errors so I have been trying to fix them as they pop up. The one in particular that was giving me trouble today was:

[b]NSString *contents = [NSString stringWithContentsOfFile:fullpath];[/b]



After doing a bit of Googling I found the solution. 



Replace NSString *contents = [NSString stringWithContentsOfFile:fullpath]; with:



[b]NSString *contents = [NSString stringWithContentsOfFile:fullpath encoding:NSUTF8StringEncoding error:nil];[NSString stringWithContentsOfFile:fullpath encoding:NSUTF8StringEncoding error:nil];[/b]