Challenge 1
[code]#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// Challenge 1 (NSString 16)
NSString *listOfNames = @"huhuWARDdsfadfadsfsadfafsfsadfafr";
NSString *capListOfNames = [listOfNames uppercaseString];
NSString *name = @"WaRdd";
NSString *capName = [name uppercaseString];
NSRange match = [capListOfNames rangeOfString:capName];
if (match.location == NSNotFound)
{
NSLog(@"No match faound!");
}else{
NSLog(@"Found!");
NSLog(@"location : %d",(int)match.location);
NSLog(@"length : %d",(int)match.length);
NSLog(@"The portion is from %d to %d",(int)match.location,(int)match.location + (int)match.length);
}
}
return 0;
}[/code]
Challenge 2
[code]#import <Foundation/Foundation.h>
#import <readline/readline.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// Challenge 2 (NSString 16)
NSLog(@"hey who is cool?");
const char *name = readline(NULL);
NSString *string = [NSString stringWithUTF8String:name];
NSLog(@"yeah %@ is really dope!!",string);
}
return 0;
}[/code]