偽データ自己追加テスト--NSArray object
1890 ワード
、
// .h node ---1
struct listTestNode
{
NSString *image;
NSString *name;
};
// .m
// NSArray---------2
NSArray *testList = [[NSMutableArray alloc]init];
for(int i=0;i<3;i++)
{
struct listTestNode node;
switch (i)
{
case 0:
{
node.name = @"name1";
node.image = [[NSString alloc]initWithFormat:@" %d.jpg",i];
}
break;
case 1:
{
node.name = @"name2";
node.image = [[NSString alloc]initWithFormat:@" %d.jpg",i];
}
break;
case 2:
{
node.name = @"name3";
node.image = [[NSString alloc]initWithFormat:@" %d.jpg",i];
}
break;
default:
break;
}
[testList addObject:[NSValue valueWithBytes:&node objCType:@encode(struct listTestNode)]];
}
// tableView NSArray-------3
struct listTestNode node;
[[testList objectAtIndex:indexPath.row]getValue:&node];
、 ( )
// NSAray , objects-------1
NSArray *testImages = [[NSArray alloc] initWithObjects: @"1.jpg", @"2.jpg", @"3.jpg",@"4.jpg",nil];
// tableView NSAray-------------2
UIImageView *imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:fileName]];
fileName=[testImages objectAtIndex:[indexPath row]];