在这两种方法之间,哪种更好/更有效?更具体地说,应该使用哪一种,还是有适当的时间使用一种?
UIImage *img = [UIImage imageWithContentsOfFile:filePath];
要么
UIImage *img = [[UIImage alloc] initWithContentsOfFile:filePath];
谢谢!
编辑:我应该提到我正在使用ARC。
最佳答案
第一个返回autorelease
d对象。 imageWithContentsOfFile:
版本很有可能会调用标准构造函数,因此速度/效率不应有任何明显的差异。两者在ARC环境中的执行方式和使用方式相同。
关于ios - UIImage-imageWithContentsOfFile:vs initWithContentsOfFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17321879/