sadik hasan sadik hasan - 6 months ago 38
iOS Question

App gets crashed because object at index is beyond empty array

I am accessing data from the json web services into my application. whenever there is no json data the app gets crashed, I am using nsjsonserialization is there anyway I can find out the empty array at response itself and display the error, thus not making app gets crashed.

Answer Source

try this . . . .

NSArray * dataArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];

if (dataArray != nil) {

     // perform parsing
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download