attribute((overloadable)) test
__attribute__((overloadable)) NSString *descriptionFromValue(float value) {
return @(value).stringValue;
}
__attribute__((overloadable)) NSString *descriptionFromValue(NSRange range) {
return NSStringFromRange(range);
}
__attribute__((overloadable)) NSString *descriptionFromValue(id object) {
return [object description];
}
// And more...
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"%@", descriptionFromValue(1.0));
NSLog(@"%@", descriptionFromValue(NSMakeRange(1, 2)));
NSLog(@"%@", descriptionFromValue([NSObject new]));
}
return 0;
}