Objective-c primitive arrays
To wrap a selector or any other primitive type you need to use NSValue
. In Cocoa, SEL is some kind of pointer, so you can use [NSValue valueWithPointer:whatever]
to create it and [value pointerValue]
to get it. Or more generally, you can use [NSValue valueWithBytes:&whatever objCType:@encode(SEL)]
; it works for any type.
source to share
Apart from managing the C-style array yourself (this is definitely not the best option, IMO), the only option is to use NSArray
/ NSMutableArray
and store the numbers with NSNumber
. It's a little more annoying to get a value than with an actual numeric type, but it frees you from managing the array's memory yourself.
source to share