Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Thomas Dobson
Thomas Dobson
7,511 Points

NSParagraphStyleAttributeName

Having a hard time with the story board app. Looks like somthing has changed with is portion of the code:

attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))

NSParagraphSystelAttributeName is no longer recognized by the compiler.

Any ideas?

1 Answer

Thomas Dobson
Thomas Dobson
7,511 Points

I got it looks like apple renamed it:

attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))
Chris Solinsky
Chris Solinsky
8,314 Points

Using this code my app crashes with *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue lineBreakMode]: unrecognized selector sent to instance 0x600000425ca0'