From d8df5030cc2e4ba7dcb0a2313bb41e227f0381a6 Mon Sep 17 00:00:00 2001 From: ybeapps Date: Wed, 4 Mar 2015 01:08:26 +0200 Subject: [PATCH] Fix a crash when you try to json["NotExistElement"] you will get a crash, my fix prevent this and returns nil if so... --- Source/SwiftyJSON.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SwiftyJSON.swift b/Source/SwiftyJSON.swift index a76527eb..7d54b63e 100644 --- a/Source/SwiftyJSON.swift +++ b/Source/SwiftyJSON.swift @@ -247,7 +247,7 @@ extension JSON { get { var returnJSON = JSON.nullJSON if self.type == .Dictionary { - if let object_: AnyObject = self.object[key] { + if let object_: AnyObject = self.object.objectForKey(key) { returnJSON = JSON(object_) } else { returnJSON._error = NSError(domain: ErrorDomain, code: ErrorNotExist, userInfo: [NSLocalizedDescriptionKey: "Dictionary[\"\(key)\"] does not exist"])