I want to have a mutable array with primitives in obj-c (selectors). What's the recommended way to do this? NSArray
and those can only hold objects.
You should use an NSValue
to wrap the selector or any other primitive type you need. In Cocoa SEL is some kind of pointer, so you can use [NSValue valueWithPointer:whatever]
to construct it and [value pointerValue]
to get it out. Or, in general you can use [NSValue valueWithBytes:&whatever objCType:@encode(SEL)]
; this works for any type.