by morbidhawk · 11y ago · 0 comments
This makes a lot of sense. In Objective-C chaining too many method calls together gets ugly and you end up having to break it up into multiple lines of code for your own sanity. Take the code below, autocompletion is guaranteed to break on you for the Objective-C version.
Objective-C:
[self.view convertPoint:apoint toView:[[UIApplication sharedApplication] keyWindow]];
Swift: view.convertPoint(apoint, toView: UIApplication.sharedApplication().keyWindow)
Objc Refatored: UIApplication *application = [UIApplication sharedApplication];
UIWindow *window = [application keyWindow];
[self.view convertPoint:apoint toView:window]; [self.view convertPoint:apoint toView:self.view.window]; [self.view convertPoint:apoint toView:[UIApplication sharedApplication].keyWindow];
No reason to skip the other places where dot notation would be useful.