Skip to content

Instantly share code, notes, and snippets.

@CodeEagle
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeEagle/63b298594b97d5523100 to your computer and use it in GitHub Desktop.
Save CodeEagle/63b298594b97d5523100 to your computer and use it in GitHub Desktop.
SwiftyJSON work with HanekeSwift
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