objective-c determine if parameter is an object -


in objective-c have function prototype: -(nsstring*)formatsql:(nsstring*) sql, ... may pass function type of parameters: nsstring, nsnumber, integer, float how can determine in function if parameter object (nsstring..) or primitive (integer...)? brochpirate

if you're going have parameter accepts multiple types, can safely using obj-c objects, means using id type. can't safely inter-mingle id float, integer etc.

if wrapped floats , ints in nsnumbers, have method so:

- (nsstring *)formatsql:(id)obj {     if ([obj iskindofclass:[nsstring class]]) {         // format string     }     else if ([obj iskindofclass:[nsnumber class]]) {         // further processing required differentiate between ints , floats     } } 

there few caveats using iskindofclass:, should serve starting point.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -