
Cocoa Maker 7 - Libraries and Frameworks
Apr 13, 2010
Radio and PodcastLive Radio & Podcasts
James ( MrGeckosMedia.com ), joined by, Eduardo ( MegaEduX.com ), and John (@ ZimiPoder ), shows how Dictionaries, Arrays and Property Lists works in Cocoa. 12:40 Example code from episode. <Foundation/Foundation.h>...
Cocoa Maker 6 - Arrays, Dictionaries, and Property Lists is an episode from Cocoa Maker by Mr. Gecko. James ( MrGeckosMedia.com ), joined by, Eduardo ( MegaEduX.com ), and John (@ ZimiPoder ), shows how Dictionaries, Arrays and Property Lis...
This episode belongs to Cocoa Maker.
Use the player on this page to stream the episode online.
Published Mar 23, 2010, audio available.
James ( MrGeckosMedia.com ), joined by, Eduardo ( MegaEduX.com ), and John (@ ZimiPoder ), shows how Dictionaries, Arrays and Property Lists works in Cocoa. 12:40 Example code from episode. <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Array"); NSArray *array = [NSArray arrayWithObjects:@"Orange", @"Apple", @"Banana", nil]; for (int i=0; i<[array count]; i++) { NSLog(@"%@", [array objectAtIndex:i]); } NSLog(@"Sorting Array"); array = [array sortedArrayUsingSelector:@selector(compare:)]; for (int i=0; i<[array count]; i++) { NSLog(@"%@", [array objectAtIndex:i]); } NSLog(@"Saving Property List"); [array writeToFile:[@"~/Desktop/array.plist" stringByExpandingTildeInPath] atomically:YES]; NSLog(@"Mutable Array"); NSMutableArray *mutableArray = [NSMutableArray array]; [mutableArray addObject:@"Apples"]; [mutableArray addObject:@"Oranges"]; [mutableArray addObject:@"Bananas"]; for (int i=0; i<[mutableArray count]; i++) { NSLog(@"%@", [mutableArray objectAtIndex:i]); } NSLog(@"Removing object Oranges"); [mutableArray removeObjectAtIndex:1]; for (int i=0; i<[mutableArray count]; i++) { NSLog(@"%@", [mutableArray objectAtIndex:i]); } NSLog(@"Dictionary"); NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"Oranges", @"Name", @"Fruit", @"Type", [NSNumber numberWithBool:YES], @"Seeds", nil]; NSLog(@"Adding %@ with name %@", [dictionary objectForKey:@"Type"], [dictionary objectForKey:@"Name"]); [mutableArray insertObject:dictionary atIndex:1]; for (int i=0; i<[mutableArray count]; i++) { NSLog(@"%@", [mutableArray objectAtIndex:i]); } NSLog(@"Saving Property List using NSPropertyListSerialization"); NSData *xmlData = [NSPropertyListSerialization dataFromPropertyList:mutableArray format:NSPropertyListXMLFormat_v1_0 errorDescription:nil]; [xmlData writeToFile:[@"~/Desktop/mutableArray.plist" stringByExpandingTildeInPath] atomically:YES]; NSLog(@"Mutable Dictionary"); NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionary]; [mutableDictionary setObject:@"Salad" forKey:@"Name"]; [mutableDictionary setObject:@"Veggie" forKey:@"Type"]; [mutableDictionary setObject:[NSDate date] forKey:@"Time"]; [mutableDictionary setObject:[NSNumber numberWithBool:NO] forKey:@"Seeds"]; NSLog(@"Adding %@ with name %@", [mutableDictionary objectForKey:@"Type"], [mutableDictionary objectForKey:@"Name"]); [mutableArray insertObject:mutableDictionary atIndex:0]; for (int i=0; i<[mutableArray count]; i++) { NSLog(@"%@", [mutableArray objectAtIndex:i]); } NSLog(@"Saving Binary Property List"); NSData *binaryData = [NSPropertyListSerialization dataFromPropertyList:mutableArray format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil]; [binaryData writeToFile:[@"~/Desktop/bina ry.plist" stringByExpandingTildeInPath] atomically:YES]; [pool drain]; return 0; } Keynote used in this Episode Keynote in PDF Format
You can listen to Cocoa Maker 6 - Arrays, Dictionaries, and Property Lists online on Radio and Podcast. Open the player on this page to stream the available audio.
Cocoa Maker 6 - Arrays, Dictionaries, and Property Lists is an episode from Cocoa Maker by Mr. Gecko.
The episode duration depends on the source podcast feed and may not always be available.
This episode was published on Mar 23, 2010.
Yes. Use the heart button on the episode page to add it to your favorite episodes list.
Yes. This page shows related episodes from Cocoa Maker when more episodes are available from the podcast feed.
You can listen to Cocoa Maker 6 - Arrays, Dictionaries, and Property Lists on this page when the episode audio is available from the podcast feed.
Cocoa Maker 6 - Arrays, Dictionaries, and Property Lists is from Cocoa Maker by Mr. Gecko.
Published Mar 23, 2010