If NSString stringWithContentsOfFile is deprecated, what is its replacement?

前端 未结 2 1418
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 23:36

I have some sample code from Tuaw which is probably 3 releases old ;) The compiler is issuing a warning that the method is deprecated, but I do not see that mentioned in the SD

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-14 00:35

    A more capable method replaced the old one. Use:

    + (id)stringWithContentsOfFile:(NSString *)path
                      usedEncoding:(NSStringEncoding *)enc
                             error:(NSError **)error
    

    Enjoy! Check out the documentation for more information.

提交回复
热议问题