PXDToolkit 0.2.0

PXDToolkit 0.2.0

DocsDocumented
TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2016
SPMSupports SPM

Maintained by pixeldock.


Downloads

Total148
Week0
Month18

Installs

Apps7
Test Targets2
powered by Segment

GitHub

Stars5
Watchers1
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files8
SizeIntegration Size 40 kb
FrameworkCreates Framework
LOCLines of Code 91


  • By
  • Jörn Schoppe

PXDToolkit

Requirements

iOS 8.0 or Greater

Installation

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

pod "PXDToolkit"

Usage

Int

Random Int between 0 and 10

let randomInt = 10.random


Array

Get random element from Array

let randomElement = ["A", "B", "C"].randomElement

Get 2 random elements from Array

let randomElements = ["A", "B", "C"].randomElements(2)

Shuffle array (order elements randomly)

let shuffledArray = ["A", "B", "C"].shuffled


UIColor

Color from hex int value

let darkRedColor = UIColor(hex: 0xAA0000)

Hex string from Color

let redColorHexString = UIColor.redColor().hexString


CGFloat

Degrees to Radians

let angleRadians = CGFloat(180).degreesToRadians

Radians to Degrees

let degrees = CGFloat(3.1415).radiansToDegrees


NSDate

Compare dates with “<”, “>” and “==”

if dateA < dateB {
   print("dateA is the earlier date")
}
if dateA > dateB {
   print("dateA is the later date")
}
if dateA == dateB {
   print("dateA is the same date as dateB")
}


NSLocalizedString

If your Localizable.strings file contains this:

"GREETING" = "Hello";
"TEMPERATURE" = "It is %f.01°C in %@";

You can do this: Get localized string for a key

print(LocalizedString("GREETING")) // "Hello"

And this: Get localized string with dynamic parts

print(LocalizedString("TEMPERATURE", arguments:[21.8, "Paris"])) // "It is 21.8°C in Paris"


UIApplication

Get App version

let appVersion = UIApplication.appVersion()

Get Build number

let buildNumber = UIApplication.appBuild()


Timing Functions

Delay

Delays the execution of the closure. Always runs on the main thread.

delay(seconds: 2) {
   print("hello!")
}

Author

Jörn Schoppe, [email protected]

Comments and suggestions are highly welcome!

License

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