rondinellimorais / RMExtensionKit

A lot of useful class

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RMExtensionKit

CI Status Version License Platform

Overview

RMExtesionKit is simple structure that contains the extension methods that simplifies the use of cocoa classes iOS / OSX.

Here are some classes that contains several useful extensions:

  • String

    • Properties

      • empty
      • length
    • Methods

      • toArray
      • substring
      • test (regex)
      • encodeURIComponent
      • toHTML
      • toDictionary
      • anymore...
  • UITableView

    • methods
      • rowHeight (base on cell identifier)
  • UIView

    • methods
      • showBorder
      • toImage
      • loadNibView
  • Date

    • properties

      • isToday
    • methods

      • addSeconds
      • addHours
      • timeInterval
      • compareTo
      • differecesDay (in days)
      • init(year, month, day, hour, minute, second)
      • anymore...

CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C, which automates and simplifies the process of using 3rd-party libraries like RMExtensionKit in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

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

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'TargetName' do
pod 'RMExtensionKit'
end

Usage Extensions

NSDate

Create simple date

let birthDate = Date(year: 1987, month: 10, day: 08)
print(birthDate)

Get time internal

let birthDate = Date(year: 1987, month: 10, day: 08)
print(birthDate.timeInterval())

Date format

let birthDate = Date(year: 1987, month: 10, day: 08)
print(birthDate.toString("yyyy/MM/dd"))

Custom formatter dates

var now = Date()
        
/* Formatters */
                
// EEEE, MMMM d, yyyy        
print("\(now.weekDayString), \(now.monthString) \(now.day), \(now.year)")
                
// MM/dd/yyyy       
print("\(now.month)/\(now.day)/\(now.year)")
        
        
        
/* change Locale */        
now.locale = Locale(identifier: "pt-BR")
                
print("\(now.weekDayString), \(now.day) de \(now.monthString) de \(now.year)")

NSURLConnection

Check if internet is connected

if NSURLConnection.isConnectedToNetwork() {
  print("Yes! Connected!")
}

String

JSON String to dictionary

{
  "array": [
    1,
    2,
    3
  ],
  "boolean": true,
  "null": null,
  "number": 123,
  "object": {
    "a": "b",
    "c": "d",
    "e": "f"
  },
  "string": "Hello World"
}
let JSONString = "{\"array\":[1,2,3],\"boolean\":true,\"null\":null,\"number\":123,\"object\":{\"a\":\"b\",\"c\":\"d\",\"e\":\"f\"},\"string\":\"Hello World\"}"
        print( JSONString.toDictionary() )

Bind HTML text

let htmlString = "<span style='color:red'>Hello world!</span><br/><span>This is a simple HTML text. This is <b>bold!</b></span>"
self.htmlTextLabel.attributedText = htmlString.toHTML()

Replace with regex

print("My password is: 12345678".replace("\\d", newValue: "*") )

See documentations for anymore!

Author

Rondinelli Morais, rondinellimorais@gmail.com

License

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

About

A lot of useful class

License:MIT License


Languages

Language:Swift 95.7%Language:Ruby 4.3%