by seanalltogether · 12y ago · 0 comments
-(void)addNumber:(NSNumber*)num withString:(NSString*)str;
How is this called in swift? Is it myobj.addNumber(42, withString:"Hello World")? myobj.addNumber(42, withString:"Hello World")
edit: I see you removed your equals - your guess is now correct :)for more details, see this link on apple's docs (may change)
https://developer.apple.com/library/prerelease/ios/documenta...
UIColor *color = [UIColor colorWithRed:0.5 green:0.0 blue:0.5 alpha:1.0];
let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
Wow, this just brings up more questions, is the compiler removing the "colorWith" semantics or do you write your own translator?They do explicitly state that initializers will get "init" and "initWith" stripped off and whatever follows becomes the first parameter. The fact that "colorWithRed" is translated to "red" might indicate that it is looking for the keyword "With"
-(void)addNumber:(NSNumber)num withString:(NSString)str;
to addNumber_withString(num, str)
Swift could be different, though.so if it has to be something, it might be myobj.addNumberWithString(42, "Hello world")