How to check if an array of links is null or empty in iphone sdk?

I want to check whether my empty arrayor nulland not nullor is not empty. Below is an example of the code I wrote. Can you tell me if this is on the right track?

  /// first time get data there
{
    Bonds = Null;
    User =     {
        DOB = "12/09/1988";
        about = "test about";
        city = CA;
    };
    success = True;
}
////////Second time get data there   
{
    Bonds =     (
                {
            DOB = "12/09/1988";
            about = "";
            city = CA;
    },
            {
        DOB = "12/09/1988";
        about = "";
        city = CA;
    }
);
User =     {
    DOB = "12/09/1988";
    about = about;
    city = CA;
};
success = True;}
+4
source share
7 answers
                 @try
                 {
                    if([Your_array objectAtIndex:int]== (id)[NSNull null] || [Your_array objectAtIndex:int]==0)
                     {
                         // if index get null
                     }
                     else
                     {
                         //your code if array index is not null 
                     }
                 }

                 @catch (NSException * e)
                 {
                     NSLog(@"NSException");
                 }
+2
source
if (!array || !array.count){
     ......
    }
+1
source

, Objective C ( iPhone SDK, Swift Objective C), .

if ([myArray count]==0) // the array is empty
{
  ...
}
0

if(![Bonds isKindOfClass:[NSArray Class]]) // for non nil array and
    if([Bounds firstObject]) //to check if array having at least one element
0

, - , .

if (!array || !array.count){
     ......
    }
0

 if(array && ![array isEqual:[NSNull null]] && [array count] > 0)
 {

 }
0

if ((NSNull*) Bonds !=[NSNull null] && Bonds!=nil && [array count] > 0)
{

}
0

All Articles