TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by HFCoreUI.
Depends on: | |
TinyLog | >= 0 |
SwiftKeychainWrapper | >= 0 |
To run the example project, clone the repo, and run pod install
from the Example directory first.
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'HFUtility'
target.build_configurations.each do |config|
if config.name == 'Debug'
config.build_settings['OTHER_SWIFT_FLAGS'] = '-D' 'DEBUG'
else
config.build_settings['OTHER_SWIFT_FLAGS'] = ''
end
end
end
end
end
Now you can freely print sensitive logs using log, logw, loge.
if boolean(view?.hidden) {
// do your fantastic job
}
if boolean(view?.hidden, defaultValue: false) {
// do your fantastic job
}
if integer(view?.subviews.count) > 0 {
// do your fantastic job
}
if integer(view?.subviews.count, defaultValue: 0) > 0 {
// do your fantastic job
}
if cgfloat(view?.frame.size.width) <= self.view.width {
// do your fantastic job
}
if cgfloat(view?.frame.size.width, defaultValue: self.view.width) <= self.view.width {
// do your fantastic job
}
HFAsync.invokeAsync(
1, // initial delay interval before start worker closure
worker: {
// do your job async
}, completion: {
// notify or update UI, this closure gonna be called in main thread.
})
HFVersion.systemVersionEqualTo("9.3")
HFVersion.systemVersionGreaterThan("9.3")
HFVersion.systemVersionGreaterThanOrEqualTo("9.3")
HFVersion.systemVersionLessThan("9.3")
HFVersion.systemVersionLessThanOrEqualTo("9.3")
HFVersion.versionEqualTo("9.3", comparedTo: "9.2")
HFVersion.versionGreaterThan("9.3", comparedTo: "9.2")
HFVersion.versionGreaterThanOrEqualTo("9.3", comparedTo: "9.2")
HFVersion.versionLessThan("9.3", comparedTo: "9.2")
HFVersion.versionLessThanOrEqualTo("9.3", comparedTo: "9.2")
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"
This feature moved to another repository, click link below.
https://github.com/DragonCherry/HFSecurity
HFUtility is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HFUtility"
DragonCherry, [email protected]
HFUtility is available under the MIT license. See the LICENSE file for more info.