I'm using the runtime functions to get the type of a property (thanks to eJames for helping me to figure out this way). The attribute string of the property looks like this:
T@"NSArray",&,Vstuff
I need to check if the property type is an array, at the moment I'm doing it like this:
- (BOOL)valueForKeyIsArray:(NSString *)key fromTagret:(id)target
{
NSString *lowerCaseKey = [self convertToKVCKey:key];
objc_property_t property = class_getProperty([target class], [lowerCaseKey UTF8String]);
NSString *propertyAttrs = [NSString stringWithUTF8String:property_getAttributes(property)];
NSString *encodedType = @"@\"NSArray\"";
NSRange range = [propertyAttrs rangeOfString:encodedType options:NSLiteralSearch];
return range.location != NSNotFound;
}
But since Apple can change the type definition string at any time, I would like to generate this @"NSArray" type string. I tried it with @encode(), but it did not work:
NSString *encodedType = [NSString stringWithUTF8String:@encode(NSArray *)];
So how can I generate this type string? Or is there a better way to check if this property attributes contain the array type?