My server is responding some json like below:
"MyData":
[
{
"name": "narendar",
"address": "san rafael"
}
]
some times I get null in name param:
"MyData":
[
{
"name": null,,
"address": "san rafael"
}
]
I am displaying these tow values in two UITextView like below:
if ([myArray objectForKey
"name"])
{
self.name.text = [myArray objectForKey
"name"];
}
then my code get crashed if name comes with null,.
To handle this situation I have changed my code like below and its working now:
if ([myArray objectForKey
"category"] != [NSNull null])
{
// body skips for null, and this code doesn't executes.
self.name.text = [selectedDeal objectForKey
"name"];
}
Now my question is do I need to compare objectForKey with [NSNull null] ?
Please let me know how to handle this situation when server sends null,, at least it should not be crashed.
"MyData":
[
{
"name": "narendar",
"address": "san rafael"
}
]
some times I get null in name param:
"MyData":
[
{
"name": null,,
"address": "san rafael"
}
]
I am displaying these tow values in two UITextView like below:
if ([myArray objectForKey
{
self.name.text = [myArray objectForKey
}
then my code get crashed if name comes with null,.
To handle this situation I have changed my code like below and its working now:
if ([myArray objectForKey
{
// body skips for null, and this code doesn't executes.
self.name.text = [selectedDeal objectForKey
}
Now my question is do I need to compare objectForKey with [NSNull null] ?
Please let me know how to handle this situation when server sends null,, at least it should not be crashed.