Ramaraj T
Ramaraj T

Reputation: 5230

NSArray object count strange issue

I initialize a NSArray like below.

    NSArray *myArr  = [[NSArray alloc]initWithObjects:name, empID, phone, email, website, nil];

myArr is supposed to have 5 elements. But [myArr count] shows only 4 elements.

EDIT:

One of the object website was nil in the array.

Upvotes: 2

Views: 73

Answers (1)

Stephen Darlington
Stephen Darlington

Reputation: 52565

Are you sure that all five of your objects are valid? If website is nil your array would only have four elements.

You can't add nil objects to a dictionary. You can add a special NSNull object if you need to do something equivalent.

Upvotes: 4

Related Questions