__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;
}
Last active
July 18, 2018 04:59
-
-
Save sunnyxx/26658b2aadc9b821fa0c to your computer and use it in GitHub Desktop.
__attribute__((overloadable)) test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment