how do i check an array if objectatIndex has any values? im using a forloop
for (i = 0; i < 6 ; i++)
{
if ([array objectAtIndex: i] == NULL)//This doesnt work.
{
NSLog(@"array objectAtIndex has no data");
}
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t store
nilin a Foundation collection class such asNSArray, you have to useNSNull. To check to see if a member of the array isNSNull, you would do this:If you want to see how many items are in the array, use
-[NSArray count]. If you want to iterate through the array to see if any object isNSNull, but you don’t care which one, you could use fast enumeration or-[NSArray containsObject:]:or