New Open Source Package: SwiftTitleCase
I just released a new open source package, SwiftTitleCase. This package contains a Swift function that tries its best to transform strings to AP style title case.
Example usage:
import SwiftTitleCase
let titleCased = "mango baby is a product under mango umbrella".titleCase()
print(titleCased) // Mango Baby Is a Product Under Mango Umbrella
Why SwiftTitleCase?
Mango Umbrella has an in-house client app managing its content. I needed a convenience button that automatically transforms my blog post's titles to AP style title case. So I wrote a basic function just doing that.
Why "tries its best"?
Currently the implementation only handles the basic rules. It doesn't attempt to identify parts of speech contextually. For example, if "up" is used as an adverb rather than a preposition, this package would still lowercase it (unless it's the first or last word). Contributions welcome!