ios - UIImage-imageWithContentsOfFile:vs initWithContentsOfFile

标签 ios objective-c uiimage

在这两种方法之间,哪种更好/更有效?更具体地说,应该使用哪一种,还是有适当的时间使用一种?

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/

相关文章:

iphone - 在 Socket :didReadData:withTag 上调用时 CocoaAsyncSocket 似乎失败

删除文件后 iOS 仍然可以引用文件

java - 在 iOS7 中编码 UIImage 并在 Java 中解码(Base64)

ios - 向 JSON Web 服务检索失败发送空值或无值

ios - UIImage 在 vi​​ewController swift 上出现晚了 2-3 秒

iphone - 以编程方式在 mainWindow 上创建 UIView

iphone - 带有 UIActivityIndi​​cator 的 UIAlertView 显示得太晚/线程问题

ios - Swift 是否可以继承轻量级通用 Objective-c 类?

objective-c - 避免 Cocoa 类中未使用的 C 回调函数警告

iphone - iOS:ImageIO 在矩形图像上调整大小