1
finab 2014-09-23 15:57:03 +08:00
用objc写调用方法
利用重载设置常用的参数调用个数 swift调用objc写的调用方法 |
2
0x001 OP Objective_C code:
@interface DemoObject : NSObject - (void)showName:(NSString *)name, ...; - (void)showTitle:(NSString *)title; @end @implementation DemoObject - (void)showName:(NSString *)name, ... { NSLog(@"name=%@", name); } - (void)showTitle:(NSString *)title { [self showName:title, @""]; } @end Swift Code: var obj = DemoObject() obj.showTitle(""); obj.showName(""); //compile error here |