私はNSOBjectであるVehicleクラスを持っています。vrn、make、model、yearmade の 4 つの文字列変数があります。Web サービスを介して取得したデータから Vehicle オブジェクトを作成し、各オブジェクトを nsmutablearray に格納しています。格納された各オブジェクトの可変配列から変数 vrn、make、model、yearmade にアクセスするにはどうすればよいですか?
編集:私はこれを試しました:
[[myArray objectAtIndex:indexPath.row] objectAtIndex:0];
編集2:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//NSLog(@"test");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell;
if ([tableView isEqual:vrnTable]) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.opaque = NO;
vrnLabel = [[UILabel alloc] initWithFrame:CGRectMake(60.0, 7.0, 50.0, 30.0)];
vrnLabel.font = [UIFont systemFontOfSize:12.0];
vrnLabel.textAlignment = UITextAlignmentRight;
vrnLabel.textColor = [UIColor whiteColor];
vrnLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
vrnLabel.backgroundColor = [UIColor clearColor];
vrnLabel.tag = VRN_LABEL_TAG;
[cell.contentView addSubview:vrnLabel];
makeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0, 7.0, 10.0, 30.0)];
makeLabel.font = [UIFont systemFontOfSize:12.0];
makeLabel.textAlignment = UITextAlignmentRight;
makeLabel.textColor = [UIColor whiteColor];
makeLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
makeLabel.backgroundColor = [UIColor clearColor];
makeLabel.tag = MAKE_LABEL_TAG;
[cell.contentView addSubview:makeLabel];
modelLabel = [[UILabel alloc] initWithFrame:CGRectMake(200.0, 7.0, 10.0, 30.0)];
modelLabel.font = [UIFont systemFontOfSize:12.0];
modelLabel.textAlignment = UITextAlignmentRight;
modelLabel.textColor = [UIColor whiteColor];
modelLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
modelLabel.backgroundColor = [UIColor clearColor];
modelLabel.tag = MODEL_LABEL_TAG;
[cell.contentView addSubview:modelLabel];
yearLabel = [[UILabel alloc] initWithFrame:CGRectMake(120.0, 7.0, 10.0, 30.0)];
yearLabel.font = [UIFont systemFontOfSize:12.0];
yearLabel.textAlignment = UITextAlignmentRight;
yearLabel.textColor = [UIColor whiteColor];
yearLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
yearLabel.backgroundColor = [UIColor clearColor];
yearLabel.tag = YEAR_LABEL_TAG;
[cell.contentView addSubview:yearLabel];
}
else {
vrnLabel = (UILabel *)[cell.contentView viewWithTag:VRN_LABEL_TAG];
}
}
NSString *cell_image = [NSString alloc];
if (indexPath.row != 0) {
cell_image = [NSString stringWithFormat:@"color%d.png", indexPath.row % 8 + 1];
}
else {
cell_image = [NSString stringWithFormat:@"color%d.png", 0];
}
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:cell_image] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
vrnLabel.text = ((Vehicle *)[entries objectAtIndex:indexPath.row]).vrn;
return cell;
}