const char numericEncodings[] = {
'c',
'i',
's',
'l',
'q',
'C',
'I',
'S',
'L',
'Q',
'f',
'd',
};
const size_t sizeEncodings[] = {
sizeof(char),
sizeof(int),
sizeof(short),
sizeof(long),
sizeof(long long),
sizeof(unsigned char),
sizeof(unsigned int),
sizeof(unsigned short),
sizeof(unsigned long),
sizeof(unsigned long long),
sizeof(float),
sizeof(double),
};
@encode 是用于表示一个类型的字符串,对此,苹果有专门的介绍文档:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
if([value isKindOfClass:[NSNumber class]]) { if (strcmp([value objCType], @encode(float)) == 0) { [cell.detailTextLabel.text = [NSString stringWithFormat:@"%.3f", [value floatValue]]]; } else if (strcmp([value objCType], @encode(double)) == 0) { [self.subTitleString appendString:[NSString stringWithFormat:@"%.3f", [value floatValue]]]; } else if (strcmp([value objCType], @encode(int)) == 0) { [self.subTitleString appendString:[NSString stringWithFormat:@"%d", [value intValue]]]; } else [self.subTitleString appendString: [NSString stringWithFormat:@"%d", [value intValue]]];