Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created October 31, 2008 19:58
Show Gist options
  • Select an option

  • Save wfarr/21410 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/21410 to your computer and use it in GitHub Desktop.
#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