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.
I want to have a mutable array with primitives in obj-c (selectors). What’s the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use an
NSValueto 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.