Created
November 4, 2014 19:48
-
-
Save finder39/2eb4b3d3d80c009d7447 to your computer and use it in GitHub Desktop.
jsonDictionaryHelpers.swift
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
// 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