Skip to content

Instantly share code, notes, and snippets.

@mdznr
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save mdznr/941e9271585effdb8d9a to your computer and use it in GitHub Desktop.

Select an option

Save mdznr/941e9271585effdb8d9a to your computer and use it in GitHub Desktop.
How do you best align function calls on multiple lines?
// 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))
@ethnt
Copy link

ethnt commented Jun 5, 2014

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