重版出来!剧情简介

"; NSRange range = [text rangeOfString:@"
"]; NSLog(@"range = %@",NSStringFromRange(range)); for (NSUInteger i = 0; i < 10; i) { NSLog(@"i = %ld", i); } //定义一个数组 NSMutableArray *array = [NSMutableArray array]; //往数组里面添加一些元素 [array addObject:@"1"]; [array addObject:@"2"]; //定义一个字符串 NSMutableString *str = [[NSMutableString alloc]initWithCapacity:100]; for (NSString *s in array) { //把数组里面的内容拼接到字符串里面去 [str appendString:s]; } //定义一个字典 NSMutableDictionary *dict = [NSMutableDictionary dictionary]; //往字典里面增加一些键值对 [dict setObject:@"1" forKey:@"2"]; [dict setObject:@"2" forKey:@"2"]; //利用for-in循环遍历字典里面所有的键值对 for (NSString *key in dict) { NSLog(@"%@ --- %@",key, [dict objectForKey:key]); } //定义一个集合 NSSet *set = [NSSet setWithObjects:@"5",@"6",@"7",@"8",@"9", nil]; //利用for-in循环来遍历集合里面的所有元素 for (NSString *s in set) { NSLog(@"%@", s); } //一个数组 NSMutableArray *mArr = [NSMutableArray arrayWithObjects:@"abcd", @"efgh", nil]; //数组元素枚举器 NSEnumerator *enumerator = [mArr objectEnumerator]; //遍历数组元素 id s; while (s = [enumerator nextObject]) { NSLog(@"%@", s); } NSMutableString *str1 = [NSMutableString stringWithString:@"123"]; NSMutableString *str2 = [NSMutableString stringWithString:@"abc"]; NSMutableString *str3 = [NSMutableString stringWithString:@"xyz"]; //定义一个数组 NSArray *array1 = [NSArray arrayWithObjects:str1, str2, str3, nil]; //定义一个数组迭代器 NSEnumerator *e = [array1 objectEnumerator]; //遍历数组元素 id ob = nil; while (ob = [e nextObject]) { NSLog(@"%@", ob); }} (void)findMaxAndMinNumber:(NSArray *)array{ //找到数组中的最大值 最小值 //最大的值 int max = 0; //最小的值 int min = 0; //遍历数组中的元素 for (NSNumber *number in array) { //把数组中的第一个元素赋值给max和min max = [number intValue]; min = max; break; } //遍历数组中的元素 for (NSNumber *number in array) { //判断数组中的元素与最大的元素的大小 if (max < [number intValue]) { max = [number intValue]; } //判断数组中的元素与最小的元素的大小 if (min > [number intValue]) { min = [number intValue]; } } NSLog(@"数组的最大值是%d, 最小值是%d", max, min);}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ //1. 开辟新线程 //采用NSObject中的方法,创建线程 [NSThread detachNewThreadSelector:@selector(action) toTarget:self withObject:nil]; //开辟一条线程,执行action方法 //当开辟一条线程之后,不知道新开辟线程能否执行,所以会把新开辟的线程置入就绪状态,等待CPU调度执行 //开辟的多条线程对象,执行的对象方法都是一样的,就是代理对象本身 //2. 创建