//// main.m// obj-c学习1//// Created by itfanr on 14/12/6.// Copyright (c) 2014年 itfanr. All rights reserved.//#import#import "Person.h"void searchString(){ NSString * str = @"hello" ; NSString *sub_str1 = @"he" ; NSRange nr1 = [str rangeOfString: sub_str1] ; if (nr1.location == NSNotFound) { NSLog(@"没有找到") ; }else{ NSLog(@"找到的范围是%@" , NSStringFromRange(nr1)) ; } NSString *sub_str2 = @"ge" ; NSRange nr2 = [str rangeOfString: sub_str2] ; if (nr2.location == NSNotFound) { NSLog(@"没有找到") ; }else{ NSLog(@"找到的范围是%@" , NSStringFromRange(nr2)) ; } }int main(int argc, char *argv[]) { @autoreleasepool{ searchString() ; } return 0;}