NSValueTransformer for C structs in Core Data
-
20-06-2021 - |
Domanda
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?
Soluzione
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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow