Cocoa and Cocoa Touch also provide some mutable versions of its immutable classes. Once a mutable object is created, its contents can be partially or completely removed or modified. As we saw immutable array objects—an instance of NSArray—in the previous topic, I will now show you its mutable version, the NSMutableArray
class, from which we will create our objects as an instance, as you can see in the following code:
/* ============================================= We will create now a mutable version of an array, using the class NSMutableArray. ============================================= */ NSMutableArray *mutableSampleArray = [[NSMutableArray alloc] init]; /* ============================================= Now, we assign to it the list of strings: "String 1", "String 2", "String 3" ============================================= */ mutableSampleArray = @[@"String 1", @"String 2", @"String 3"]; /* =========================================...