Latest 0.4.9
Homepage https://github.com/meetkei/KeiSwiftFramework
License MIT
Platforms ios 8.0
Authors

Version
License
Platform

Usage

Date

Time Interval
// 1 hour 30 min
let interval = 1.hour + 30.minute       // 5400.0
let min = interval.minuteInterval       // 90.0
let hour = interval.hourInterval        // 1.5

let yesterday = Yesterday.startDate
let now = Today.now
let minInterval = (now - yesterday).minuteInterval
let hourInterval = (now - yesterday).hourInterval
Date Components
let now = NSDate()
let tenMinutesBefore = now - 10.minute
let twoHoursAfter = now + 2.hour

let month = now.month
Compare NSDate
let date1 = NSDate(timeIntervalSince1970: 0)
let date2 = NSDate()

if date1 < date2 {
    print("asc")
} else if date1 > date2 {
    print("desc")
} else {
    print("same")
}
// Supported Operators : ==, !=, <, <=, >, >=

let now = Today.now
if now == KWeekday.Sunday {
    // ...
}

if now == KMonth.March {
    // ...
}

Color

Parse Hex Color String #RGB, #ARGB, #RRGGBB, #AARRGGBB
let hexString = "#03a9f4"
let color = UIColor(hexString: hexString)
let color2 = hexString.UIColorValue

if hexString.isHexColorString {
    // ...
}

if let color = hexString.parseHexColorString() {
    // ...
}

CoreData Setup

class AppDelegate: KApp {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        setupCoreData(modelName: "Model Name")
        // or
        setupCoreData(modelName: "Model Name", storeType: NSSQLiteStoreType, useLightweightMigration: true)

        return true
    }
}

Time Profiler

KTimeProfiler.start()                       // Required
// ...
KTimeProfiler.checkpoint()
// ...
KTimeProfiler.checkpoint("Create File")
// ...
KTimeProfiler.checkpoint("Save to DB")
// ...
KTimeProfiler.report(verbose: true)

// Verbose Report
// KTimeProfiler: application(_:didFinishLaunchingWithOptions:) in 0.801861s
// ==================================================
// Start            0
// Checkpoint 1    +0.100269
// Create File     +0.301065
// Save to DB      +0.200434
// End             +0.200093
// ==================================================
// total            0.801861
// ==================================================

File & Directory

NSURL Extension
let url = NSURL(fileURLWithPath: ...)

// read only
url.name
url.exist
url.isDirectory
url.fileSize
url.creationDate
url.lastAccessDate
url.modificationDate

// read/write
url.hidden
url.excludedFromBackup
Prevent files from being backed up to iCloud and iTunes
url.excludedFromBackup = true
// or
url.addSkipBackupAttribute()
// or
NSFileManager.defaultManager().addSkipBackupAttributeToItemAtURL(url)
// or
do {
    try url.addSkipBackupAttributeOrThrows()
    // or
    try NSFileManager.defaultManager().addSkipBackupAttributeToItemAtURLOrThrows(url)
} catch {}

Requirements

iOS 8 or higher

Installation

KeiSwiftFramework is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "KeiSwiftFramework"

Author

Keun young Kim, [email protected]

License

KeiSwiftFramework is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "KeiSwiftFramework",
    "version": "0.4.9",
    "summary": "Swift Utility Framework",
    "description": "Kei's Swift Utility Framework",
    "homepage": "https://github.com/meetkei/KeiSwiftFramework",
    "license": "MIT",
    "authors": {
        "Keun young Kim": "[email protected]"
    },
    "source": {
        "git": "https://github.com/meetkei/KeiSwiftFramework.git",
        "tag": "0.4.9"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "KeiSwiftFramework/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This