Go to file
Rahim Khalid 761abf1a56 Creating and updating sync dictionary for storing and cache dateFormatter for later use and memory management with updating unit test for Cache Dict. 2019-05-11 22:18:25 -07:00
EZSwiftExtensions Fixed almost all Swiftlint warnings 2017-08-25 12:17:25 -07:00
EZSwiftExtensions.xcodeproj Creating and updating sync dictionary for storing and cache dateFormatter for later use and memory management with updating unit test for Cache Dict. 2019-05-11 22:18:25 -07:00
EZSwiftExtensions.xcworkspace Merge in master EZSE 2018-09-30 00:26:57 -07:00
EZSwiftExtensionsExample Added base64 to UIImageExtensions (#363) 2017-03-09 00:55:34 -03:00
EZSwiftExtensionsExample.xcodeproj Final merge for swift 4 (#476) 2018-06-22 19:26:59 -07:00
EZSwiftExtensionsTests Creating and updating sync dictionary for storing and cache dateFormatter for later use and memory management with updating unit test for Cache Dict. 2019-05-11 22:18:25 -07:00
Sources Creating and updating sync dictionary for storing and cache dateFormatter for later use and memory management with updating unit test for Cache Dict. 2019-05-11 22:18:25 -07:00
.codecov.yml Exclude the paths of example and tests from code coverage calculation 2016-10-23 15:56:25 +08:00
.gitignore Adding gitignore for files generated by AppCode. 2017-09-10 20:24:40 -07:00
.swift-version Final merge for swift 4 (#476) 2018-06-22 19:26:59 -07:00
.swiftlint.yml Fixed almost all Swiftlint warnings 2017-08-25 12:17:25 -07:00
.travis.yml Reverting certain swift 4.1 mandatory changes. 2018-08-25 19:48:20 -07:00
CHANGELOG.md Add hashString changelog entry 2018-09-30 00:26:57 -07:00
CONTRIBUTING.md Adding PR ettiquette for Contributions. 2017-09-25 10:56:59 -07:00
Dangerfile Not showing multiple file error bug (#450) 2017-08-31 14:29:44 -03:00
EZSwiftExtensions.podspec Switching to new versioning scheme. 2018-08-26 13:19:47 -07:00
Gemfile Added danger-xcode_summary 2016-10-12 10:06:23 -03:00
LICENSE Adding PR ettiquette for Contributions. 2017-09-25 10:56:59 -07:00
PULL_REQUEST_TEMPLATE.md Removed 2016-11-01 08:57:24 -07:00
README.md Adding swift 4 tag post release. 2018-07-03 13:56:00 -07:00
charizard.png +images to readme 2015-11-14 20:39:43 +02:00

README.md

EZSwiftExtensions

Carthage compatible CocoaPods Compatible
License Platform Language Language Language

Build Status codecov.io MIT

How Swift standard types and classes were supposed to work. A collection of useful extensions for the Swift Standard Library, Foundation, and UIKit.

Join our online chat at Gitter

Example Usage

Easily get an object at a specified index:

var myArray = ["charmander","bulbasaur","squirtle"]
print(myArray.get(1)) // "bulbasaur"

Easily access a random element:

var myArray = ["charmander","bulbasaur","squirtle"]
print(myArray.random()) // bulbasaur or something else

Easily find the indexes of an object:

var myArray = ["charmander","bulbasaur","squirtle","charmander"]
print(myArray.indexesOf("charmander")) // [0,3]

Easily check if an array contains another array:

var myArray = ["charmander","bulbasaur","squirtle"]
print(myArray.containsArray(["charmander","bulbasaur"])) // true
print(myArray.containsArray(["string"])) // false

Block Objects These objects use completion blocks instead of selectors, taken from: CEMKit-Swift Easily initialize a BlockButton:


let button = BlockButton(x: 0, y: 0, w: 100, h: 100) { (sender) -> Void in
    print("Block button clicked!")
}
let button1 = BlockButton(x: 0, y: 0, w: 100, h: 100)
button1.addAction { (sender) -> Void in
    print("Block button clicked!")
}

// There are also BlockWebView, BlockTap, BlockPan, BlockSwipe, BlockPinch, BlockLongPress

Easily convert between different types:

var myCGFloat = myInt.toCGFloat
var myString = myInt.toString
var myDouble = myString.toDouble
var myInt = myDouble.toInt

Easily toggle it:

var myBool: Bool = true
print(myBool.toggle()) // false

Easily initialize your objects:

let myView = UIView(x: 0, y: 0, w: 100, h: 100)
print(myView.frame) // (0.0, 0.0, 100.0, 100.0)

Easily access your ViewController on top of your view stack:

ez.topMostViewController?.presentViewController(myAlertController, animated: true, completion: nil)
// topMostViewController is your rootViewController
// Intended for showing small VCs like UIAlertControllerstring.length, string.capitalizefirst, string.trim, string.isemail, 

Easily initialize your colors:

let myColor = UIColor(r: 100, g: 100, b: 100) // Default alpha is 1

Easily run block of codes after a certain delay:

Timer.runThisAfterDelay(seconds: 2) { () -> () in
    print("Prints this 2 seconds later in main queue")
}

Easily run code every seconds:

var count = 0
Timer.runThisEvery(seconds: 1) { (timer) -> Void in
    print("Will print every second")
    if count == 3 {
        timer?.invalidate()
    }
    count += 1
}

Easily access your projects version and build numbers:

print(ez.appVersion) // 0.3
print(ez.appBuild) // 7
print(ez.appVersionAndBuild) // v0.3(7)

Easily track screen shots:
ez.detectScreenShot { () -> () in
    print("User took a screen shot")
}

Installation

Manually (~10 seconds)

  1. Download and drop '/Sources' in your project.
  2. Congratulations!

Install via CocoaPods (~10 seconds)

You can use CocoaPods to install EZSwiftExtensions by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'EZSwiftExtensions' #Stable release for Swift 3.0

pod 'EZSwiftExtensions', :git => 'https://github.com/goktugyil/EZSwiftExtensions.git' #Latest release for Swift 3.0
pod 'EZSwiftExtensions', :git => 'https://github.com/goktugyil/EZSwiftExtensions.git', :branch => 'Swift2.3' #For Swift 2.3
pod 'EZSwiftExtensions', '~> 1.6' #For Swift 2.2

To get the full benefits import EZSwiftExtensions wherever you import UIKit

import UIKit
import EZSwiftExtensions

Install via Carthage

Create a Cartfile that lists the framework and run carthage bootstrap. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/EZSwiftExtensions.framework to an iOS project.

github "goktugyil/EZSwiftExtensions"

Requirements

  • Swift 2 or later

Possible features

  • More extensions! Please if there is an extension you are constantly using, send a pull request now!
  • Fancy pictures and jpgs in documentation.
  • Documentations inside code
  • List of contents inside readme
  • Completing TODOs in source code.
  • OSX compatibility and add here https://github.com/AndrewSB/awesome-osx

Sources Used

And countless gists and stackoverflow answers.

License

EZSwiftExtensions is available under the MIT license. See the LICENSE file.

Keywords

swift, extension, uikit, exswift, foundation, library, framework, tool