I have been playing with JSON for the last two days and am facing a lot of interesting problems and thanks to the stack overflow, this helps me. it is JSON featured, has a tow type of String Type values.
"featured":"1"
or
"featured": null,
I tried a lot to handle this, but failed
step 1) if dict.objectForKey("featured") as? String != nil { featured = dict.objectForKey("featured") as? String }
step 2)
let null = NSNull() if dict.objectForKey("featured") as? String != null { featured = dict.objectForKey("featured") as? String }
step 3)
if dict.objectForKey("featured") as? String != "" { featured = dict.objectForKey("featured") as? String }
but unfortunately cannot find a solution, you will answer.
json null swift core-data
Ayaz Akbar
source share