Last active
August 29, 2015 14:23
-
-
Save CodeEagle/63b298594b97d5523100 to your computer and use it in GitHub Desktop.
SwiftyJSON work with HanekeSwift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension SwiftyJSON.JSON : DataConvertible, DataRepresentable { | |
public typealias Result = SwiftyJSON.JSON | |
public static func convertFromData(data:NSData) -> Result? { | |
if let obj: AnyObject = NSKeyedUnarchiver.unarchiveObjectWithData(data) { | |
return SwiftyJSON.JSON(obj) | |
} | |
return nullJSON | |
} | |
public func asData() -> NSData! { | |
var obj: AnyObject! = self.dictionaryObject | |
if obj == nil { | |
obj = self.arrayObject | |
} | |
if obj != nil { | |
return NSKeyedArchiver.archivedDataWithRootObject(obj!) | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment