Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

How to check an NSMutableArray is null or not ?

like image 501
S.P. Avatar asked Jan 12 '10 10:01

S.P.


People also ask

What is difference between NSArray and NSMutableArray?

The primary difference between NSArray and NSMutableArray is that a mutable array can be changed/modified after it has been allocated and initialized, whereas an immutable array, NSArray , cannot.

What is NSMutableArray in Swift?

Overview. The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior inherited from NSArray .


1 Answers

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) { ... } 
like image 185
Alex Reynolds Avatar answered Oct 27 '22 10:10

Alex Reynolds