ios – Swift:CGPathRelease和ARC

ios – Swift:CGPathRelease和ARC,第1张

概述刚刚更新到 Xcode Beta 4,并注意到以下编译器错误,我的代码如下: var path = CGPathCreateMutable()...CGPathRelease(path) ‘CGPathRelease’ is unavailable: Core Foundation objects are automatically memory managed 所以,我只是删除我的发布呼叫, 刚刚更新到 Xcode Beta 4,并注意到以下编译器错误,我的代码如下:
var path = CGPathCreateMutable()...CGPathRelease(path)

‘CGPathRelease’ is unavailable: Core Foundation objects are
automatically memory managed

所以,我只是删除我的发布呼叫,一切都应该没问题?还是有更多我想念的东西? ARC有什么特殊情况需要注意吗?

解决方法 使用Swift与Cocoa和Objective-C的 Working with Cocoa Data Types部分说(强调我的):

Core Foundation objects returned from annotated APIs are automatically memory managed in Swift—you do not need to invoke the CFRetain,CFRelease,or CFautorelease functions yourself. If you return Core Foundation objects from your own C functions and Objective-C methods,annotate them with either CF_RETURNS_RETAINED or CF_RETURNS_NOT_RETAINED.

When Swift imports APIs that have not been annotated,the compiler cannot automatically memory manage the returned Core Foundation objects. Swift wraps these returned Core Foundation objects in an Unmanaged<T> structure.

所以,是的,除非你有一个非托管结构,这是正确的,你不必担心手动释放对象.

总结

以上是内存溢出为你收集整理的ios – Swift:CGPathRelease和ARC全部内容,希望文章能够帮你解决ios – Swift:CGPathRelease和ARC所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1095673.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存