Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
6 NSArray *array = 7 [NSArray arrayWithContentsOfFile: 8 @"example.plist"]; 9 NSData *data = [NSData dataWithContentsOfFile: 10 @"example.plist"]; 11 NSMutableArray *mutable = 12 [NSPropertyListSerialization 13 propertyListFromData: data 14 mutabilityOption: 15 NSPropertyListMutableContainersAndLeaves 16 format: NULL 17 errorDescription: NULL]; 18 NSCAssert([mutable isKindOfClass: 19 [NSMutableArray class]], 20 @"Should have read a mutable array"); 21 [[mutable objectAtIndex: 0] 22 appendString: @"suffix"]; |
There are two ways of reading in a property list. The first is to use the inverse of the method that we just looked at for writing them. Both of the collection classes that support property list serialization have an -initWithContentsOfFile: initializer, as well as a corresponding constructor.