Created
September 14, 2009 14:56
-
-
Save jduff/186700 to your computer and use it in GitHub Desktop.
This file contains 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]; | |
// insert code here... | |
NSLog(@"Hello, World!"); | |
NSString *path = @"~"; | |
path = [path stringByExpandingTildeInPath]; | |
NSLog(@"My home folder is at '%@'", path); | |
NSEnumerator *pathComponents = [[path pathComponents] objectEnumerator]; | |
NSString *obj; | |
while ( obj = [pathComponents nextObject] ) { | |
NSLog(obj); | |
} | |
NSProcessInfo *process = [NSProcessInfo processInfo]; | |
NSLog(@"Process Name: '%@', Process ID: '%@'", [process processName], [NSString stringWithFormat:@"%d",[process processIdentifier]]); | |
NSMutableDictionary *bookmarks = [NSMutableDictionary dictionaryWithCapacity:5]; | |
[bookmarks setObject:[NSURL URLWithString:@"http://www.stanford.edu"] forKey:@"Stanford University"]; | |
[bookmarks setObject:[NSURL URLWithString:@"http://www.apple.com"] forKey:@"Apple"]; | |
[bookmarks setObject:[NSURL URLWithString:@"http://cs193p.stanford.edu"] forKey:@"CS193P"]; | |
[bookmarks setObject:[NSURL URLWithString:@"http://itunes.stanford.edu"] forKey:@"Stanford on iTunes U"]; | |
[bookmarks setObject:[NSURL URLWithString:@"http://stanfordshop.com"] forKey:@"Stanford Mall"]; | |
for(id obj in bookmarks) { | |
if([obj hasPrefix:@"Stanford"]==true) | |
NSLog(@"Key: '%@' URL: '%@'",obj, [[bookmarks objectForKey:obj] absoluteString]); | |
} | |
NSString * string=@"string"; | |
NSArray *array = [NSArray arrayWithObjects:process, bookmarks, path, string, nil]; | |
for(id obj in array){ | |
NSLog(@"========================"); | |
NSLog(@"Class name: %@",[obj className]); | |
NSLog(@"Is Member of NSString: %@",([obj isMemberOfClass:[NSString class]] ? @"YES" : @"NO")); | |
NSLog(@"Is Kind of NSString: %@",([obj isKindOfClass:[NSString class]] ? @"YES" : @"NO")); | |
NSLog(@"Is Member of NSString: %@",([obj isMemberOfClass:[NSString class]] ? @"YES" : @"NO")); | |
NSLog(@"Responds to lowercaseString: %@",([obj respondsToSelector:@selector(lowercaseString)] ? @"YES" : @"NO")); | |
if([obj respondsToSelector:@selector(lowercaseString)]==true) | |
NSLog(@"lowercaseString is: %@", [obj performSelector:@selector(lowercaseString)]); | |
} | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment