Aboue Hook function
if you want use hook, need to implement HurryPorterHookDelegate.
below is some exmaple.
Hook for CheckResponse
This delegate call when get server response data. (if connection is success and no server error)
return true or false decide HurryPorter callback onSuccess or onFailed.
class HookTestCheckResponse : HurryPorterHookDelegateCheckResponse{
func verifyData(porter: HurryPorter, json: [String : AnyObject]?, raw: String) -> Bool {
NSLog("on hook.verifyData:" + raw)
guard let dict = json else{
return false
}
if let status = dict["status"] as? NSNumber{
let code = status.integerValue
if code == 1000 {
return true
}
}
if let status = dict["status"] as? String{
if status == "1000"{
return true
}
}
return false
}
func errorMessage(porter: HurryPorter, json: [String : AnyObject]?, raw: String) -> String? {
return "Just Error"
}
}