Frage

i have an NSMutableArray that gives this output in the debug area:

finalArray  (
        (
    )
)

Now i want an if else statement to do something if this is the output. I tryd this:

NSArray *emptyArray = @[];
if (finalArray == nil || finalArray == emptyArray)
{
    NSLog(@"foobar");
}

How can i check if my array is this output?

War es hilfreich?

Lösung

Your array consists of another item (probably also an array) which is empty.

To check for that, you can use:

if(finalArray.firstObject.count == 0)
{
    NSLog(@"It's empty!");
}

Andere Tipps

You can count the items of the array with the following code:

if([emptyArray count] == 0) {
    NSLog(@"array is empty");
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top