How to check if an instance of NSMutableArray is null or not

S.P. picture S.P. · Jan 12, 2010 · Viewed 32.7k times · Source

How to check an NSMutableArray is null or not ?

Answer

Alex Reynolds picture Alex Reynolds · Jan 12, 2010

If you want to check if it is empty:

if ([myMutableArray count] == 0) { ... }

If you want to check if the variable is nil:

if (!myMutableArray) { ... }

or:

if (myMutableArray == nil) { ... }