Cover Page by Stephen G. Kochan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

17. Memory Management and Automatic Reference Counting

Recall the NSMutableArray class that enables you to create an array that you can add objects to and remove objects from. Suppose that at the start of execution of your program you need to read the contents of a file into an array. Assume you want to call new array myData and you want to initialize its contents from a file that is stored in the form of a property list (covered in more detail in Chapter 19, “Archiving”). You can do this with a single method call using NSArray’s arrayWithContentsOfFile: method like so:

NSSArray *myData = [NSArray arrayWithContentsOfFile: @"database1"];

This reads and parses the file and stores the resulting elements into a newly created array, returning the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required