Skip to content

SireAI/SireAutoNSCoding

Repository files navigation

SireAutoNSCoding

CI Status Version License Platform

== If you like SwiftAutoNSCoding and use it, could you please:

star this repo

send me some feedback. Thanks! ##Basic usage

Consider you have a object data like this:

import Foundation

class MallInfor: Store {
	var Code: String = "1"
	var ExceptionMsg: String = "对象序列化"
	var Msg: String = "成功"
	var RequestId: String = "33"
	var Result: SeckillListEntity?
	override var description: String {
		return "Code:\(Code)  \n" + "ExceptionMsg:\(ExceptionMsg)  \n" + "Msg:\(Msg)  \n" + "Result.BrandCountryLogo:\(Result?.BrandCountryLogo)  \n"
	}
}

class SeckillListEntity: Store {
	var BrandCountryLogo: String = "中国"
	var BuyNumber: Int = 2
	var CountryName: String? = "中国"
	var DisCount: Int = 3
	var Features: String? = "壮丽"
	var ImageNameFull: String? = "图片名称"
	var InStock: Bool = false
	var ItemCode: String? = "4444"
	var MarketPrice: String?
	var Name: String?
	var PromotionDescription: String?
	var PromotionPrice: String?
	var ShortName: String? = "华夏"
}

###save data object to disk

		// raw data
		let oldInfor = MallInfor()
		// change some value
		oldInfor.Code = "100000"
		oldInfor.Msg = "what a new day"
		oldInfor.ExceptionMsg = "no error"
		oldInfor.Result = SeckillListEntity()
		oldInfor.Result!.BrandCountryLogo = "world china"

		// save to disk
		oldInfor.storeToDisk()

###recover data from disk

   let newInfor = MallInfor.recoverFromDisk("\(MallInfor.self)")

##Attention

  • object must inherit Store

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod "SireAutoNSCoding", :git => 'https://github.com/SireAI/SwiftAutoNSCoding.git'

Author

Sire, 1120523212@qq.com
Sire的博客

##MyOther Projects SireJSONModel

License

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

About

Automaticlly NSCoding object(自动将对象 NSCoding序列化,对象存储,对象读取)

Resources

License

Stars

Watchers

Forks

Packages

No packages published