ios - 使用 ARC 编码和解码 CGMutablePathRef

标签 ios memory-management automatic-ref-counting nscoding cgpath

在 ARC 下,是否可以使用 NSCoding 编码/解码 CGMutablePathRef(或其非可变形式)?我天真地尝试:

path = CGPathCreateMutable();
...
[aCoder encodeObject:path]

但是我从编译器那里得到了一个友好的错误:

Automatic Reference Counting Issue: Implicit conversion of an Objective-C pointer to 'CGMutablePathRef' (aka 'struct CGPath *') is disallowed with ARC

我该怎么做才能对此进行编码?

最佳答案

NSCoding 是一个协议(protocol)。它的方法只能用于符合 NSCoding 协议(protocol)的对象。 CGPathRef 甚至不是一个对象,所以 NSCoding 方法不会直接工作。这就是您收到该错误的原因。

Here's a guy谁想出了一种序列化 CGPath 的方法。

关于ios - 使用 ARC 编码和解码 CGMutablePathRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9938864/

相关文章:

iphone - 在哪些情况下我们不能简单地依赖自动引用计数?

ios - NSRegularExpression 用于标签和带有特殊字符的提及?

ios - 从过滤后的数组中在 tableView 中显示数据

ios - Swift - 在旋转时将 UIImageView 保持在相同位置

ios - 无法使用分发配置文件签署我的 ios 应用程序

c++ - 如何在没有 'new' 的情况下将新对象实例添加到 std::list

C++ 内存编辑 - 编辑汇编/写入字节

iOS UIImageView 内存未在 ARC 上释放

c - 如何连续声明结构而不将其设为数组?

objective-c - 将属性公开为只读