Loading

Friday, September 26, 2014

Get primitive type from NSNumber

 const char* type = [theValue objCType];
if (strcmp (type, @encode (NSInteger)) == 0)
{
    //It is NSInteger
}
else if (strcmp (type, @encode (NSUInteger)) == 0)
{
    //It is NSInteger
}
else if (strcmp (type, @encode (int)) == 0)
{
    //It is NSUInteger
}
else if (strcmp (type, @encode (float)) == 0)
{
    //It is float
}
else if (strcmp (type, @encode (double)) == 0)
{
    //It is double
}
else if (strcmp (type, @encode (long)) == 0)
{
    //It is long
}
else if (strcmp (type, @encode (long long)) == 0)
{
    //It is long long
}