I need to create an Nsmutableattributed String that starts with line break, the code are like below:
let dateString = TimeUtils.formatTimeOnly(from: data.date!)
let dateMutableString = NSMutableAttributedString.init(string: "\n\(dateString)")
let range = NSRange(location: 0, length: (dateString.count + 2))
dateMutableString.addAttributes([NSFontAttributeName: UIFont(name: "SourceSansPro-Regular", size: 11)!, NSForegroundColorAttributeName: UIColor.gray], range: range)
if I only start the string with only one \n it will crashed the program on the addattributes line, but if I use \n\n then it wont break the program. Can I know what's really going on here?