Вопрос

How do I create a NSValueTransformer for a C struct, such as a CGRect in Core Data?

Apparently transformedValue & reverseTransformedValue require and id. Is there a way to pass a void*, or a better way to do this?

Это было полезно?

Решение

Use NSValue to wrap C pointers.

[NSValue valueWithPointer:&struct]

Specifically for CGRect, you can use

[NSValue valueWithCGRect:rect]

which is declared in UIKit/UIGeometry.h

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top