Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
NSDictionary - ObjectiveC       Share
2011-06-28 |  MalathiVanaraj  | Viewed: 1302  |    1

#import <Foundation/NSString.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/Foundation.h<
#import <stdio.h>

void print( NSDictionary *map ) {
NSEnumerator *enumerator = [map keyEnumerator];
id key;

while ( key = [enumerator nextObject] ) {
printf( "%s => %s\n",
[[key description] cString],
[[[map objectForKey: key] description] cString] );
}
}

int main( int argc, const char *argv[] ) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
@"one", [NSNumber numberWithInt: 1],
@"two", [NSNumber numberWithInt: 2],
@"three", [NSNumber numberWithInt: 3],
nil];
NSMutableDictionary *mutable = [[NSMutableDictionary alloc] init];

// print dictionary
printf( "----static dictionary\n" );
print( dictionary );

// add objects
[mutable setObject: @"Tom" forKey: @"tom@jones.com"];
[mutable setObject: @"Bob" forKey: @"bob@dole.com" ];

// print mutable dictionary
printf( "----mutable dictionary\n" );
print( mutable );

// free memory
[dictionary release];
[mutable release];
[pool release];

return 0;
}


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Prof: Software Engineer
Tech: C ,Cpp
Send Mail: ratheesh



Related topics
UIView slide transition

Related References
iphone coding: slider tutorial

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us