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:
-
-
Properties
- empty
- length
-
Methods
- toArray
- substring
- test (regex)
- encodeURIComponent
- toHTML
- toDictionary
- anymore...
-
-
- methods
- rowHeight (base on cell identifier)
- methods
-
- methods
- showBorder
- toImage
- loadNibView
- methods
-
-
properties
- isToday
-
methods
- addSeconds
- addHours
- timeInterval
- compareTo
- differecesDay (in days)
- init(year, month, day, hour, minute, second)
- anymore...
-
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
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
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"))
Check if internet is connected
if NSURLConnection.isConnectedToNetwork() {
print("Yes! Connected!")
}
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!
Rondinelli Morais, [email protected]
RMExtensionKit is available under the MIT license. See the LICENSE file for more info.