Latest 1.1.1
Homepage https://github.com/awd1559/SwiftyExt
License MIT
Platforms ios 8.0, requires ARC
Authors

Resize icon
Siwft Extensions

Install:

pod 'SwiftyExt'

Usage:

String

//change to value
"true".toBool() // true
"2.00".toFloat() // 2.0
"2.00".toInt() // 2
"2014-06-03".toDate() // NSDate
"2014-06-03 13:15:01".toDateTime() // NSDate
"2.00".toDouble() // 2.0

//is judge
"fdafaf3".isAlpha() // false
"afaf35353afaf".isAlphaNumeric() // true
"33.0".isNumeric() // true
" ".isEmpty() // true
"hello world".isStartsWith("hello") // true
"hello world".isEndsWith("world") // true
"foobar".contains("foo") // true

//get substring
"hello world"[0...1] // "he"
"hello world"[0..<1] // "h"
"hello world"[0] // "h"
"hello world"[0...10] // "hello world"

"<a>foo</a>".between("<a>", "</a>") // "foo"

//set substring
var value = "foobar"
var.replace("foo", "fff")   //"fffbar"
var.replace(0, 3, "bbb")    //"bbbbar"

//misc
"hi".times(3) // "hihihi"

",".join(["a","b","c"]) // "a,b,c"

"hello world".split(" ")[0] // "hello"

String.rangeFromNSRange(NSRange) -> Range<Int>
"The Weekend &#8216;King Of The Fall&#8217;".decodeHTML() // "The Weekend ‘King Of The Fall’"
"<strong> 4 &lt; 5 &amp; 3 &gt; 2 .</strong> Price: 12 &#x20ac;.  &#64; ".decodeHTML() // "<strong> 4 < 5 & 3 > 2 .</strong> Price: 12 €.  @ "
"this is so &quot;good&quot;".decodeHTML() // "this is so "good""

UIColor

UIColor(r:255, g:0, b:0)
UIColor(r:255, g:0, b:0, a:0.5)

GCD

let task = delay(5) {
    //do somthing
}
cancle(task)

UIImage

//image with rounded corner
let image = UIImage(named:"ok.png")
image.roundedCornerImageWithCornerRadius(3.0) 

Misc

NSObject.Identifier()

Reference:

Latest podspec

{
    "name": "SwiftyExt",
    "version": "1.1.1",
    "summary": "useful extensions for Swift",
    "description": ""useful extensions for Swift"",
    "homepage": "https://github.com/awd1559/SwiftyExt",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "authors": {
        "awd1559": "[email protected]"
    },
    "source": {
        "git": "https://github.com/awd1559/SwiftyExt.git",
        "tag": "1.1.1"
    },
    "source_files": [
        "SwiftyExt/*.swift",
        "SwiftyExt/SwiftyExt.h"
    ],
    "public_header_files": "SwiftyExt/SwiftyExt.h"
}

Pin It on Pinterest

Share This