Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

NSMutableArray example

Here we have discussed about NSMutableArray and how to add and remove objects in NSMutableArray.


NSMutableArray example Comparing the various Open Source Java iOS Tools Top 10 Health Applications for iPhone Maximizing the iPhone 3G Experience, Getting the Most Out of iPhone 3G What is iPhone iPhone News and Updates Installing iPhone SDK What is iPhone SDK? iPhone Tutorials iPhone Programming tutorials and examples Access Modifiers and Garbage Collection Objective C Constructors Objective-C keywords iPhone Class and Method declaration and definitions Message Expressions and comments Andrew Stone Designs Twitter Applications Purchase iPhone Without Contract Apple iPhone in China Finally Apple Unlocks the Bluetooth Features on iPhone iPhone 3.0 SDK Mac launches Cha-Ching feature in iPhone Using iPhone for the Nintendo Wii iPhone 3.0 is finally here! Blackboard Inc. Develops Seamless Learning for iPhone Users iPhone News Reliability of iPhone 3G iPhone 3G Comparison Flash on iPhone 3G Maximize Your iPhone 3G Experience The iPhone as a Business Phone iPhone 3G Buying Guide Top iPhone 3G Downloads Sites Tips and Guide iPhone 3G as a Gaming Device iPhone's Missing Features iPhone 3G vs iPhone 2G iPhone Cost and Pricing iPhone Troubleshooting Guide iPhone Application Store Submission and Acceptance Process iPhone Security and Safety Tips iPhone 3G FAQ Best iPhone Accessories and Attachments All iPhone Tips and Tricks iPhone Development in 2009 iPhone Application Development iPhone Advantages and Disadvantages Objective C Objective-c Dealloc Objective-c memory management: retain and release Dynamic Types in Objective-C

In this section we will discuss about the NSMutableArray with some examples to clarify its use in programming.

NSMutableArray class adds insert and delete operations to handle array, which it inherits from NSArray. NSMutableArray class declares the interface that maintains a changeable collection of objects.

Why do we need to subclass NSMutableArray?

NSMutableArray class maintain a changeable collection of objects. But when storing the elements of collection or receiving information about collection, custom NSArray object is used.

Example of Creating and and adding object in NSMutableArray:

First create a object of NSMutableArray in the header file

NSMutableArray *array;

//And property
@property(nonatomic, retain)NSMutableArray *array;
in the viewDidLoad method(in implementation file) initialize the array and add objects to it given below.

array = [[NSMutableArray alloc]init]; [array addObject:@"uber uns"]; [array addObject:@"Weiterempfehlen"]; [array addObject:@"App Bewerten"];

Example of creating NSMutablearray, adding objects and then removing all the objects:

NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject:@"One"];
[myArray addObject:@"Two"];
[myArray removeAllObjects];
[myArray release];


Share on Google+Share on Google+

NSMutableArray example

Posted on: October 4, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: NSMutableArray example  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image