TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jul 2016 |
SPMSupports SPM | ✗ |
Maintained by HFCoreUI.
Depends on: | |
HFUtility | >= 0 |
RNCryptor | >= 0 |
SwiftKeychainWrapper | >= 0 |
ReachabilitySwift | >= 0 |
To run the example project, clone the repo, and run pod install
from the Example directory first.
This project contains simple methods that can reduce common and repetitive codes we always writing in iOS application development. The major features are as follows.
To save into or load from local dictionary(suppose that you have an object somewhere like below)
let storage = HFLocalStorage(fileName: "test.db", directoryType: .LibraryDirectory)
storage.saveObject(["Any", "Kinds", "Of", "NSCoding", "Objects"], "TEST_KEY") // save
let array = storage.loadObject("TEST_KEY") as? [String] // load
To archive object that conforms to protocol NSCoding,
NSKeyedArchiver.archiveObject("path/to/file", object: objectToArchive, key: "OBJECT_KEY")
To unarchive archived NSCoding-conformed object from file,
let unarchivedObject = NSKeyedArchiver.archiveObject("path/to/file", key: "OBJECT_KEY")
Suppose that you have JSON string from server or somewhere,
let dict = HFJSON.jsonFrom(jsonResponseText)
let jsonString = HFJSON.stringFrom(dict)
Suppose that a dictionary with data is given below,
{
"productList": [{
"productId": 0,
"productName": "Product 0",
"components": [{
"componentId": 100,
"componentName": "Component 100",
"parts": [{
"partId": 1000,
"partName": "Part 1000"
},{
"partId": 2000,
"partName": "Part 2000"
}]
}
}
}
To get second part name of first component of first product, just call extension method below.
// where jsonDict is an object type of [String: AnyObject]?
let partName = jsonDict?.objectForKeyPath("productList[0].components[0].parts[1].partName") as? String
NSLog("partName: \(partName)") // will get "Part 2000"
Everything will work as you expected.
HFCore is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HFCore"
DragonCherry, [email protected]
HFCore is available under the MIT license. See the LICENSE file for more info.