i want to convert id* to NSNumber *
trying this
unsigned int ShortValue = [(NSNumber *)idObject unsignedShortValue];
but this aint compiling
Cast of an indirect pointer to an Objective-C pointer to 'NSNumber *' is disallowed with ARC
any ideas how to do it.
basically id* object will be argument to my method ,second argument will be type information of this id* object then inside this method i am performing type specific methods on it like one above
idis a semi-primitive type, as it is declared in objc.h asWhen you create id objects, you don’t use an “*”, as that is for pointers to objects, so basically don’t do this:
The correct syntax would be this:
Hope this helps!
——–EDIT——
I tried out the code you used:
and it compiled fine. I think the error is how you create
idObject.———EDIT———
Here’s an apple doc on
id: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocObjectsClasses.htmland here’s two good resources on the
isapointer: What does isa mean in objective-c?, http://cocoasamurai.blogspot.com/2010/01/understanding-objective-c-runtime.html. In the second link, scroll to the top third of the article to find info onisa*. Hope this helps!