A collection of helpful tools for iOS app development.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
YMKit.xcodeproj
YMKit
.gitignore
LICENSE
README.md
YMKit.podspec

README.md

YMKit

YMKit is a collection of helpful tools for iOS app development.

This framework extends built-in types, such as Date, Double, and UIColor, with shorthands for common manipulations, as well as introduces a new type, YMFormatter, for advanced formatting. For example, you can quickly get date strings without messing with DateFormatter.

WARNING

The code of YMKit is pretty unstable—it’s not even in beta. Please don’t use it in production environments until further notice.

Installation

Use CocoaPods to install YMKit. If you’ve never used it before, watch this detailed (and funny) video from Google on how to install and use CocoaPods.

To install YMKit, add the pod to your podfile:

pod 'YMKit'

Install the newly-added pod with the following Terminal command:

pod install

Open the the created/updated workspace.

Code Examples

Here are a few examples of what YMKit can do.

Date & Time Strings

You can call getDateString(withStyle:), getTimeString(withStyle:), and getDateTimeString(in:dateStyle:timeStyle:) on values of the Date type for getting string representations of dates without using DateFormatter every time.

let date = Date()

print(date.getDateString(withStyle: .short))
// 1/15/19

print(date.getTimeString(withStyle: .medium))
// 9:41:57 AM

print(date.getDateTimeString(in: Locale(identifier: "fr_FR"), dateStyle: .long, timeStyle: .short))
// 15 janvier 2019 à 9:41


print(date.getDateTimeString())
// January 15, 2019 at 9:41 AM

ISO 8601 Dates

ISO 8601 is an ISO standards-based date/time format. It encodes dates as strings that look like 2019-01-15T9:41:57Z. With YMKit, you can both initialize instances of Date with ISO 8601 strings and get strings from values of Date. Required iOS 10 or later.

let date = Date(fromISO8601String: "2019-01-15T9:41:57Z")
// date is optional

print(date!.iso8601String)
// 2019-01-15T9:41:57Z

Localized Strings

Use the localized computed property and the localized(withParameters:) method on String values to get the corresponding localized strings defined in Localizable.strings.

// Localizable.strings

"HelloWorld" = "¡Hola, mundo!";
"WelcomeBack" = "Welcome %@! Your last login was on %@.";

// Your code

print("HelloWorld".localized)
// ¡Hola, mundo!

usernameLabel.text = "WelcomeBack".localized(withParameters: user.username, user.lastLogin.getDateString(withStyle: .medium))
// Welcome jason532! Your last login was on Jan 15, 2019.

In localized(withParameters:), the number and types of parameters should match your localized string, or you’ll get a runtime error.

UIColor

Initialize colors with HEX codes.

let gold = UIColor(hexString: "#ffd700")

Documentation

A proper documentation will be available in the following weeks.

Contributions & Bug Reports

I am unable to accept code contributions at the moment.

However, if you see a bug, I’d be grateful if you contacted me about it using the email address that’s on my profile. GitHub issues are coming soon.