Last active
August 29, 2015 14:02
-
-
Save mdznr/941e9271585effdb8d9a to your computer and use it in GitHub Desktop.
How do you best align function calls on multiple lines?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In Objective-C, a relatively long method call could be easily wrapped on multiple lines: | |
[attributedString addAttribute:NSParagraphStyleAttributeName | |
value:paragraphStyle | |
range:NSMakeRange(0, attributedString.length)]; | |
// But how do you do that in Swift? | |
attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) | |
// This is the closest I can get, but it's still pretty ugly. | |
attributedString.addAttribute(NSParagraphStyleAttributeName, | |
value:paragraphStyle, | |
range:NSRange(location:0, length:attributedString.length)) |
This is how I generally deal with super long method calls in Ruby, not sure how well it carries over to Swift:
attributedString.addAttribute(
NSParagraphStyleAttributeName,
value:paragraphStyle
range:NSRange(
location:0,
length:attributedString.length
)
)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apple just does it straight out in one line in their UIVIewController class: