evermeer / AttributedTextView

Easiest way to create an attributed UITextView (with support for multiple links and from html)
Other
440 stars 55 forks source link

makeInteractive Crash fix when NSRange.location == NSNotFound #28

Closed jameshays closed 5 years ago

jameshays commented 5 years ago

If the range location can't be found, return without attempting to add a link. This would crash previously.

evermeer commented 5 years ago

Thanks!

I do have one question. Why are you using: guard nsRange.location != NSNotFound else { return self } Instead of just: if nsRange.location == NSNotFound { return self }

jameshays commented 5 years ago

Mainly just personal preference. To me, it reads better. If I use an “if” statement, I typically expect the body to do something. The guard is then just used more as an assert. Both accomplish the same thing in this case.