Skip to content

Instantly share code, notes, and snippets.

@finder39
Created November 4, 2014 19:48
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 finder39/2eb4b3d3d80c009d7447 to your computer and use it in GitHub Desktop.
Save finder39/2eb4b3d3d80c009d7447 to your computer and use it in GitHub Desktop.
jsonDictionaryHelpers.swift
// Created by Joseph Neuman
import Foundation
func getBool(object:AnyObject?) -> Bool? {
return object as AnyObject? as? Bool
}
func getDate(object:AnyObject?) -> NSDate? {
if let tempObject = object as AnyObject? as? String {
return getDateFormatter().dateFromString(tempObject)
} else {
return nil
}
}
func getDictionary(object:AnyObject?) -> Dictionary<String, AnyObject>? {
return object as AnyObject? as? Dictionary<String, AnyObject>
}
func getString(object:AnyObject?) -> String? {
if let temp: AnyObject = object as AnyObject? {
if let temp2 = temp as? String {
return temp2
} else if let temp2 = temp as? Int {
return String(temp2)
} else {
return nil
}
} else {
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment