in my function I have a parameter of NSObject* type, to allow to pass NSString, NSDate, etc.. and intenally do something... I need to pass also a value of type int.. how can I do this?
thanks
您可以使用NSNumber
类( http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNumber_Class/Reference/Reference.html ),并使用numberWithInt
方法对其进行初始化。
@Itamar's answer is sufficient, but I'm just simplifying it.
Try this,
NSNumber *your_object = [NSNumber numberWithInt:int_value];
So now int_value is converted into object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.