Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objective-c primitive arrays

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.

like image 422
quano Avatar asked Jun 21 '26 02:06

quano


1 Answers

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.

like image 102
newacct Avatar answered Jun 23 '26 18:06

newacct