This is a multipart answer. In the end, the answer for you is going to be "you can do this".
(1) NSArray cannot handle general C types. If you're interested in this kind of thing, CFArray can be outfitted with custom callbacks for storing other kinds of data. Caveat: Normally you can pass a CFArray to any NSArray taking API - they're bridged. This does not apply to CFArrays with custom callbacks.
(2) CGLayerRef is not any old C type, it's a CFType. CFType is bridged to NSObject. Sending -retain
and -release
to any CFType works just as it would on an NSObject. If you were to put a category on NSObject implementing -foo
and then cast some random CFType to id and send it the -foo message, you'd see your implementation of foo
invoked.
So, the compiler warning here is the only problem. You can cast to (id) to avoid it. All of this is supported.
Ken Ferry
Cocoa Frameworks