#import void PrintPathInfo() { NSString *path = @"~"; path = [path stringByStandardizingPath]; NSString *aString = [NSString stringWithFormat:@"My home folder is at: '%@'", path]; NSLog(aString); NSArray *aArray = [path componentsSeparatedByString:@"/"]; int i = 0; int o = [aArray count] - 1; while (i <= o) { if(i == 0) { NSLog(@"/"); } else { NSString* bString = [aArray objectAtIndex:i]; NSLog(bString); } i++; } } void PrintProcessInfo() { NSProcessInfo * aInfo = [NSProcessInfo processInfo]; int aInt = [aInfo processIdentifier]; NSString * aString = [aInfo processName]; NSString * bString = [NSString stringWithFormat:@"Process Name: '%@' Process ID: '%i'", aString, aInt]; NSLog(bString); } void PrintBookmarkInfo() { NSArray *keys = [NSArray arrayWithObjects: @"Stanford University", @"Apple", @"CS193P", @"Stanford on iTunes U", @"Stanford Mall", nil]; NSArray *values = [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"], nil]; NSDictionary *aDictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys]; for (id key in aDictionary) { if([key hasPrefix:@"Stanford"]) { NSLog(@"Key: '%@' URL: '%@'", key, [aDictionary objectForKey:key]); } } } void PrintIntrospectionInfo() { NSArray * aArray = [NSArray arrayWithObjects:[NSString stringWithString:@"HELLO WORLD!"],[NSURL URLWithString:@"http://www.web6.nl"],[NSDictionary init], nil]; for (id value in aArray) { //Getting the classname NSString * className = [[value class] description]; NSLog( @"Class name: %@",className); //Checking if it is a member of NSString NSString * stringChild; if ( [value superclass] == [NSString class] ) { stringChild = @"YES"; } else { stringChild = @"NO"; } NSLog(@"Is Member of NSString: %@",stringChild); //Checking if it is kind of an NSString NSString * stringKind; if ( [value isKindOfClass:[NSString class]] ) { stringKind = @"YES"; } else { stringKind = @"NO"; } NSLog(@"Is Kind of NSString: %@",stringKind); //Checking if it resomonds to selectors NSString * selectorResponse; if ([value respondsToSelector:@selector(lowercaseString)]) { selectorResponse = @"YES"; } else { selectorResponse = @"NO"; } NSLog(@"Responds to lowercaseString: %@",selectorResponse); //Prefiorm Selector if(selectorResponse == @"YES") { NSLog(@"lowercaseString is: %@",[value performSelector:@selector(lowercaseString)]); } NSLog( @"================================="); } } int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; PrintPathInfo(); // Section 1 NSLog( @"\n"); PrintProcessInfo(); // Section 2 NSLog( @"\n"); PrintBookmarkInfo(); // Section 3 NSLog( @"\n"); PrintIntrospectionInfo(); // Section 4 [pool drain]; return 0; }