扩展 0.1.0

扩展 0.1.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2016年5月
SPM支持SPM

Mark Hamilton 维护。



扩展 0.1.0

扩展

Swift 2.x编写的有用扩展的Cocoapod。

示例扩展用法

/// Value Type Extensions
var str = "Hello, playground"

str.subscript(range) // returns substring of range

str.subscript(index) // returns character at index

str.toUnicodeArray() // [72, 101, 108, 108, 111, 44, 32, 112, 108, 97, 121, 103, 114, 111, 117, 110, 100]

str.toUnicodeArray()[0].toChar() // "H"

str.toUnicodeArray().toString() // "Hello, playground"

str.length // 17 :: .length() in v0.0.1

var int: Int = 0

int.add(2) // 2

/// UITableView Extensions
var tableView: UITableView

tableView.animateData() // reloads data and animates load
tableView.animateData(1.0, delayOffset: 0.05, usingSpringWithDamping: 0.75, initialSpringVelocity: 0) // reloads data and animates

/// UIView Extensions
IBInspectable for cornerRadius

/// Delay Extension
var object: NSObject

object.delay(2) {
 // do something after 2 seconds
}

delay(2) {
 // do something after 2 seconds
}

/// Binary Search Extensions (all use throws)
func binarySearch(collection: [T], query: T) throws -> Bool
func binarySearchPrefix(collection: [String], query: String) throws -> Bool
func binarySearchFirst(collection: [String], query: String) throws -> Int
func binarySearchLast(collection: [String], query: String) throws -> Int

/// Array2D Struct
Array2D(columns: Int, rows: Int)
Array2D.subscript(column: Int, row: Int) -> Int
Array2D.columnCount()
Array2D.rowCount()

/// App Utils
AppDisplayName() -> String?
AppVersion() -> String?
AppBuildNumber() -> String?
AppBuildVersion() -> String?
DeviceVersion() -> String?
DetectScreenshot(completion: ()-> ())
IsDebug() -> Bool
IsRelease() -> Bool
IsSimulator() -> Bool
IsDevice() -> Bool

/// Device Feedback Utils
vibrate()

// NSBundle Extensions
.loadNib(name: String, owner: AnyObject!)
.loadNib<T>(name: String) -> T?

/// UIAlertController Extensions
.show() // Use RootViewController() to display alert
.showWithCompletion(completion: () -> Void) // Use RootViewController() to display alert with completion
alert.showWithCompletion() {

    // do something on completion

}
.setVisible // On set true it shows using RootViewController()

/// UIAlert Utils
showErrorAlert(description: String, error: NSError?, sender: UIViewController)
showErrorAlertUsingRoot(description: String, error: NSError?)

/// View Controller Utils
RootViewController() -> UIViewController? // Returns RootViewController in keyWindow
ScreenOrientation() -> UIInterfaceOrientation
HorizontalSizeClass() -> UIUserInterfaceSizeClass
VerticalSizeClass() -> UIUserInterfaceSizeClass
ScreenWidth() -> CGFloat
ScreenHeight() -> CGFloat
ScreenBounds() -> CGRect
StatusBarHeight() -> CGFloat
ScreenHeightMinusStatusBar() -> CGFloat

相关项目

Mark Hamilton, Dryverless的示例Swift应用

Swift / Objective-C编写的示例应用集合,用于iOS 9.x(在使用9.2.1 SDK下开发 - 发布时将迁移到9.3)

https://github.com/TheDarkCode/Example-Swift-Apps

支持

发送任何问题和请求至:[email protected]

贡献

  • 1) 分叉此仓库!
  • 2) 创建您的功能分支:git checkout -b Your-New-Feature
  • 3) 提交您的更改:git commit -am '添加一些非常棒的更新'
  • 4) 推送到分支:git push origin Your-New-Feature
  • 提交一个pull请求!

许可证

版权所有 © 2016 Mark Hamilton / dryverless (http://www.dryverless.com

任何人未经授权可免费复制、使用、复制、修改、合并、发布、分发、再许可和/或出售副本的许可,并将允许本软件的提供给供方,前提是

上述版权声明和此许可约定应包含在所有副本或实质性部分中。

本软件按“原样”提供,不提供任何形式的保证,无论是明示的还是暗示的,包括但不限于对适销性、特定目的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对因使用该软件或与该软件相关的任何行动(无论是合同、侵权或其他行动)而产生的任何索赔、损害或其他责任负责。