NSMutable NSArray Array -이 모든 선을 피하고 차원 또는 3D 배열을 사용하려면 어떻게해야합니까?


1
enter code here- (void)viewDidLoad { 

NSMutableArray *imageViewArray= [[NSMutableArray alloc] init]; 
for (int i = 1; i < 10 ; i++) { 

    NSString *imgName = [NSString stringWithFormat:@"pic%i.jpg", i]; 
    UIImage *img = [UIImage imageNamed:imgName]; 
    [imageViewArray addObject:img]; 
} 
self.gallery = imageViewArray; 
[imageViewArray release]; 


NSString *p1 = [NSString stringWithFormat:@"p1.jpg"]; 
NSString *p2 = [NSString stringWithFormat:@"p2.jpg"]; 
NSString *p3 = [NSString stringWithFormat:@"p3.jpg"]; 
NSString *p4 = [NSString stringWithFormat:@"p4.jpg"]; 
NSString *p5 = [NSString stringWithFormat:@"p5.jpg"]; 
NSString *p6 = [NSString stringWithFormat:@"p6.jpg"]; 
NSString *p7 = [NSString stringWithFormat:@"p7.jpg"]; 
NSString *p8 = [NSString stringWithFormat:@"p8.jpg"]; 
NSString *p9 = [NSString stringWithFormat:@"p9.jpg"]; 
UIImage *P1V = [UIImage imageNamed:p1]; 
UIImage *P2V = [UIImage imageNamed:p2]; 
UIImage *P3V = [UIImage imageNamed:p3]; 
UIImage *P4V = [UIImage imageNamed:p4]; 
UIImage *P5V = [UIImage imageNamed:p5]; 
UIImage *P6V = [UIImage imageNamed:p6]; 
UIImage *P7V = [UIImage imageNamed:p7]; 
UIImage *P8V = [UIImage imageNamed:p8]; 
UIImage *P9V = [UIImage imageNamed:p9]; 
NSArray *imageViewArray2 = [[NSArray alloc] initWithObjects:P1V,P2V,P3V,P4V,P5V,P6V,P7V,P8V,P9V,nil]; 
self.gallery2 = imageViewArray2; 
[imageViewArray2 release]; 

NSArray *array = [[NSArray alloc] initWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",nil]; 
self.list = array; 
[array release]; 

[super viewDidLoad]; 

}

2

당신이 배열에있는 파일 이름을 넣고 단순히 루프 내에서 그 변수를 대체 일을해야한다.

NSArray *dayStrings = [NSArray arrayWithObjects: @"Monday", @"Tuesday", @"Wednesday", @"Thursday", @"Friday", nil]; 
NSArray *timeStrings = [NSArray arrayWithObjects: @"9 AM", @"10 AM", @"11 AM", @"12 PM", @"1 PM", @"2 PM", @"3 PM", @"4 PM", @"5 PM", nil]; 

int i; 
NSMutableAttributedString *day, *time; 

for(i = 0; i < HORIZONTAL_CELL_COUNT; i++) 
{ 
    day = [[[NSMutableAttributedString alloc] initWithString:[dayStrings objectAtIndex:i] attributes:attributes] autorelease]; 
    [days addObject:day]; 
} 

for(i = 0; i < VERTICAL_CELL_COUNT; i++) 
{ 
    time = [[[NSMutableAttributedString alloc] initWithString:[timeStrings objectAtIndex:i] attributes:attributes] autorelease]; 
    [times addObject:time]; 
} 
: 여기

는 것을 입증하는 몇 가지 코드입니다