Tag: style blog color Io AR for SP Div 2014
I value convenience. What is I value convenience? We can regard I as the first letter of an integer. Here there are two ways to implement it.
The first method is to print the number of elements in the array directly.
The second is to print all elements in the array one by one.
#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { NSArray *array = [[NSArray alloc]initWithObjects:@"One", @"Tow", @"Three",nil ]; //下面这种方法是通过返回元素的个数, 并且打印出来. NSUInteger length = [array count];// 下面输出的结果是3, 而我们在数组里也是设定了三个元素. NSLog(@"%lu", (unsigned long)length); //输出结果: //2014-10-13 08:43:11.383 INSArray[3600:303] 3 //下面这种方法就是返回i代表数组里的元素地址. //比如第一次循环, 当i=0, 那么返回的就是数组里的@"One"元素的地址. NSInteger i; for(i = 0; i < length; i++) { NSLog(@"%@",[array objectAtIndex:i]); } //输出的结果是One,Tow,Three等三个元素. //2014-10-13 08:43:11.384 INSArray[3600:303] One //2014-10-13 08:43:11.385 INSArray[3600:303] Tow //2014-10-13 08:43:11.385 INSArray[3600:303] Three [array release]; } return 0;}
Convenient I-value for nsarray