macos 10.13.6
不要使用team
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hello, World!");
NSString* nothing = nil;
NSLog(@"location of nil: %p",nothing);
NSString* quote = @"dogs have masters,while cats have staff";
NSLog(@"size of string: %d",(int)[quote length]);
NSLog(@"character at 5: %c",[quote characterAtIndex:5]);//当你有参数时,使用 `:`
char* name = "ectix";
NSString* myName = [NSString stringWithFormat:@"- %s",name];
BOOL isStringEqual = [quote isEqualToString:myName];
printf("are string equal: %d\n",isStringEqual);
const char * uCString = [[myName uppercaseString]UTF8String];
printf("%s\n",uCString);
NSString* wholeQuote = [quote stringByAppendingString:myName];
NSRange searchResult = [wholeQuote rangeOfString:@"ectix"];
if(searchResult.location == NSNotFound){
NSLog(@"string not found");
}else {
printf("ectix is at index %lu and is %lu long\n",searchResult.location,searchResult.length);
}
}
return 0;
}
直接运行应该就可以了