I m trying to get an instance of NSParagraphStyle.default.mutableCopy() but are we sure that mutableCopy() will always contain a value?
var paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
Would it possible to do this without force unwraping?
Yes, it's much simpler:
let paragraphStyle = NSMutableParagraphStyle() // Note the `let`
You get the default parameters with the default initializer.
Apart from that in this case you can be sure that mutableCopy() will always contain a value because NSParagraphStyle clearly conforms to NSCopying.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With