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

前端 未结 4 1110
半阙折子戏
半阙折子戏 2020-12-30 00:20

How to check an NSMutableArray is null or not ?

4条回答
  •  庸人自扰
    2020-12-30 00:44

    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) { ... }
    

提交回复
热议问题