Created
October 31, 2008 19:58
-
-
Save wfarr/21410 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| int main (int argc, const char * argv[]) { | |
| NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
| PrintPathInfo(); | |
| PrintProcessInfo(); | |
| PrintBookmarkInfo(); | |
| // PrintIntrospectionInfo(); | |
| [pool release]; | |
| return 0; | |
| } | |
| void PrintPathInfo() { | |
| NSString *path = @"~"; | |
| path = [path stringByExpandingTildeInPath]; | |
| NSLog(@"My home folder is '%@'", path); | |
| } | |
| void PrintProcessInfo() { | |
| NSString *processName = [[NSProcessInfo processInfo] processName]; | |
| NSInteger *processIdentifier = [[NSProcessInfo processInfo] processIdentifier]; | |
| NSLog(@"Process Name: '%@' Process ID: '%d'", processName, processIdentifier); | |
| } | |
| void PrintBookmarkInfo() { | |
| NSArray *keys = [NSArray arrayWithObjects:@"Stanford University", @"Apple", @"CS193P", @"Stanford on iTunes U", @"Stanford Mall"]; | |
| NSArray *objects = [NSArray arrayWithObjects:[NSURL URLWithString:@"http://www.stanford.edu"], [NSURL URLWithString:@"http://www.apple.com"], [NSURL URLWithString:@"http://cs193p.stanford.edu"], [NSURL URLWithString:@"http://itunes.stanford.edu"], [NSURL URLWithString:@"http://stanfordshop.com"]]; | |
| NSMutableDictionary *dict = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; | |
| for (id key in dict) | |
| { | |
| if([key hasPrefix:@"Stanford"]) { | |
| NSLog(@"Key: '%@', URL: '%@'", key, [[dict objectForKey:key] absoluteString]); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment