Difference between NSArray and NSMutableArray

那年仲夏 提交于 2019-12-03 03:51:20

问题


What is the difference b/w NSArray and NSMutableArray?


回答1:


NSMutableArray (and all other classes with Mutable in the name) can be modified. So, if you create a plain NSArray, you cannot change its contents later (without recreating it). But if you create an NSMutableArray, you can change it — you'll notice it has methods like -addObject: and -insertObject:atIndex:.

See the documentation for details.




回答2:


The "mutable" types are classes which can be changed after they've been initialized, like NSMutableString vs NSString.




回答3:


NSArray : in NSArray we can not change index.... Means fix array.

NSMutableArray : in NSMutableArray we can change index and also add the value in array at run-time..



来源:https://stackoverflow.com/questions/1345215/difference-between-nsarray-and-nsmutablearray

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!