- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
刚刚更新到 Xcode Beta 4,并注意到我的代码出现以下编译器错误:
var path = CGPathCreateMutable()
...
CGPathRelease(path)
'CGPathRelease' is unavailable: Core Foundation objects are automatically memory managed
那么我是否只需删除我的发布调用,一切就应该没问题了?还是我还缺少什么?对于 ARC,我应该注意什么特殊情况吗?
最佳答案
Working with Cocoa Data Types 使用 Swift 与 Cocoa 和 Objective-C 部分说(强调我的):
Core Foundation objects returned from annotated APIs are automatically memory managed in Swift—you do not need to invoke the
CFRetain
,CFRelease
, orCFAutorelease
functions yourself. If you return Core Foundation objects from your own C functions and Objective-C methods, annotate them with eitherCF_RETURNS_RETAINED
orCF_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.
所以是的,除非你有 Unmanaged
struct,这是正确的,您不必担心手动释放该对象。
关于ios - Swift:CGPathRelease 和 ARC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37430172/
我正在使用 CGMutablePathRef 为我的 SKShapeNode 创建一条线。稍微阅读一下用法,我看到一篇文章说在使用完路径后使用 CGPathRelease 很重要。现在我想知道,我什么
是否需要将 CGPathRelease 与 CGPathCreate... 函数一起使用并使用自动引用计数?我使用了 Analyze,但两种方式都没有显示差异。 最佳答案 据我所知,CF 函数尚未由
以下是来自 Omni frameworks 的代码片段: CGMutablePathRef path = CGPathCreateMutable(); CGPathAddRect(path, NULL
刚刚更新到 Xcode Beta 4,并注意到我的代码出现以下编译器错误: var path = CGPathCreateMutable() ... CGPathRelease(path) 'CGPa
我在子类 UIImageview 中有一个 CGMutablePathRef 属性。当我创建新路径并将其分配给属性时,CGPathRelease 在我调用 CGPathContainsPoint 时会
刚更新到 Xcode Beta 4,发现我的代码出现以下编译器错误: var path = CGPathCreateMutable() ... CGPathRelease(path) 'CGPathR
我是一名优秀的程序员,十分优秀!