Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//로컬 JsonString 데이터 바인딩을 위해서 만들어놓은 Mapper
class PatientInfodata: ImmutableMappable {
var fullname : String
var lastname : String
var birthday : String
var mobile : String
var email : String
var gender : String
var statusCd : String
var insuranceData : Array<AfterSignInInsuranceData>
required init(map: Map) throws {
fullname = try map.value("fullname")
lastname = try map.value("lastname")
birthday = try map.value("birthday")
mobile = try map.value("mobile")
email = try map.value("email")
gender = try map.value("gender")
statusCd = try map.value("statusCd")
insuranceData = try map.value("insurance")
}
}
class AfterSignInInsuranceData: ImmutableMappable {
var code : String
var name : String
required init(map: Map) throws {
code = try map.value("code")
name = try map.value("name")
}
}
//암호화된 jsonString을 복호화한 것.
let userDataJsonString = AES256CBC.decryptString(data, key32: descryptionKey, iv16: descryptionIv)
//userDataJsonString을 가지고, 위의 patientInfoData에 매핑
do {
let pData = try Mapper<PatientInfodata>().map(JSONString: userDataJsonString!)
localInfo.patientData = pData
}catch {
print(error)
}
//LocalInfo에 선언된
class LocalInfo: NSObject {
var patientData : PatientInfodata!
}
//LocalInfo를 상속받은 ViewController
class ViewController : UIViewcontroleler, LocalInfo {
var pData: PatientInfoData?
override func viewDidLoad() {
super.viewDidLoad()
// Print 출력이 되지않음..
if let ppData = localInfo.patientData {
print(ppData.gender)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment