InflectorKit
InflectorKit is a lightweight library designed to make string manipulation easier by providing various inflection methods. It’s written in Objective-C and compatible with iOS, macOS, and tvOS.
Installation
To use InflectorKit in your project, you can install it via CocoaPods. Simply add the following line to your Podfile:
pod 'InflectorKit'
Usage
InflectorKit offers a range of inflection methods to modify, transform, and pluralize strings. Here are some of the most commonly used methods:
- pluralize(string:) – Pluralizes the given string.
- singularize(string:) – Singularizes the given string.
- camelized(string:) – Converts the string to camel case.
- underscored(string:) – Converts the string to snake case.
- dasherized(string:) – Converts the string to dasherized case.
- humanized(string:) – Converts the string to human-readable form.
- titleized(string:) – Converts the string to title case.
- capitalized(string:) – Converts the first character of the string to uppercase.
- uncapitalized(string:) – Converts the first character of the string to lowercase.
- ordinalize(number:) – Converts the number to its ordinal form (e.g., 1st, 2nd, 3rd).
Example usage:
let word = "apple"
print(Inflector.pluralize(word)) // Output: "apples"
let name = "john_doe"
print(Inflector.camelized(name)) // Output: "johnDoe"
let title = "the_quick_brown_fox"
print(Inflector.titleized(title)) // Output: "The Quick Brown Fox"
API Documentation
For detailed information about all available methods and their parameters, please refer to the official InflectorKit documentation.
License
InflectorKit is released under the MIT license. See the LICENSE file for more details.
Conclusion
InflectorKit simplifies string manipulation by providing numerous inflection methods, allowing you to easily transform and modify strings. With its compatibility across iOS, macOS, and tvOS, it proves to be a valuable tool for any developer working with string processing in Objective-C.