Latest 0.2.1
Homepage https://github.com/DragonCherry/HFCore
License MIT
Platforms ios 8.0
Dependencies HFUtility, RNCryptor, SwiftKeychainWrapper, ReachabilitySwift
Authors

Version
License
Platform

Example

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.

Local Data Management

  • HFLocalStorage provides simple way to save and load object

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
  • extensions of NSKeyedArchiver and NSKeyedUnarchiver provides simple way to archive and unarchive object

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")

Data Handling

  • HFJSON provides simple way to get JSON object from String, and vice versa.

Suppose that you have JSON string from server or somewhere,


let dict = HFJSON.jsonFrom(jsonResponseText)

let jsonString = HFJSON.stringFrom(dict)
  • Dictionary+HF provides simple way to pick an object from complicated dictionary

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"

Cryptors

  • HFCryptor provides simple way to encrypt, decrypt data using AES256
  • HFCryptorRSA provides simple way to encrypt, decrypt data using RSA cryptosystem

Everything will work as you expected.

Requirements

Installation

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

pod "HFCore"

Author

DragonCherry, [email protected]

License

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

Latest podspec

{
    "name": "HFCore",
    "version": "0.2.1",
    "summary": "Core Utilities for iOS Application",
    "description": "Handy framework in Swift that most commercial application may require, it contains features about encryption, decryption, JSON(Dictionary), alert, and so many useful utilities in very intuitive way.",
    "homepage": "https://github.com/DragonCherry/HFCore",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "DragonCherry": "[email protected]"
    },
    "source": {
        "git": "https://github.com/DragonCherry/HFCore.git",
        "tag": "0.2.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "HFCore/Classes/**/*",
    "dependencies": {
        "HFUtility": [],
        "RNCryptor": [],
        "SwiftKeychainWrapper": [],
        "ReachabilitySwift": []
    }
}

Pin It on Pinterest

Share This