![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/doc/gnustep-base-doc/examples/ |
Upload File : |
/* A simple demonstration of the NSDictionary object. Copyright (C) 2005 Free Software Foundation Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. In this example the NSDictionary holds int's which are keyed by strings. */ #include <Foundation/Foundation.h> #include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSDictionary.h> #include <Foundation/NSValue.h> #include <Foundation/NSString.h> int main() { NSMutableDictionary *d; CREATE_AUTORELEASE_POOL(pool); /* Create a Dictionary object. */ d = [[NSMutableDictionary alloc] initWithCapacity: 32]; /* Load the dictionary with some items */ [d setObject: [NSNumber numberWithInt: 1] forKey: @"one"]; [d setObject: [NSNumber numberWithInt: 2] forKey: @"two"]; [d setObject: [NSNumber numberWithInt: 3] forKey: @"three"]; [d setObject: [NSNumber numberWithInt: 4] forKey: @"four"]; [d setObject: [NSNumber numberWithInt: 5] forKey: @"five"]; [d setObject: [NSNumber numberWithInt: 6] forKey: @"six"]; NSLog(@"There are %u elements stored in the dictionary\n", [d count]); NSLog(@"Element %d is stored at \"%s\"\n", [[d objectForKey: @"three"] intValue], "three"); NSLog(@"Removing element stored at \"three\"\n"); [d removeObjectForKey: @"three"]; NSLog(@"Now there are %u elements stored in the dictionary\n", [d count]); DESTROY(pool); exit(0); }