Last active
April 30, 2016 12:41
-
-
Save InsertNetan/100e4fceda735c8dcbe73a2f578bfd34 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func JSONFromFile(file: String) -> AnyObject? { | |
return NSBundle(forClass: self.dynamicType).pathForResource(file, ofType: "json") | |
.flatMap { NSData(contentsOfFile: $0) } | |
.flatMap(JSONObjectWithData) | |
} | |
private func JSONObjectWithData(data: NSData) -> AnyObject? { | |
return try? NSJSONSerialization.JSONObjectWithData(data, options: []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment