UIImage - imageWithContentsOfFile:vs initWithContentsOfFile

jon*_*aff 1 objective-c uiimage ios

两种方法之间哪种更好/更有效?更具体地说,哪个应该使用,或者是否有适当的时间使用一个而不是另一个?

UIImage *img = [UIImage imageWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)

要么

UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)

谢谢!

编辑:我应该提到我正在使用ARC.

Ale*_*der 7

第一个返回一个autoreleased对象.imageWithContentsOfFile:版本调用标准构造函数的可能性很高,因此速度/效率不应有任何显着差异.在ARC环境中执行和使用相同的方式.