Iphone 如何将数组构造成UITableView?

Iphone 如何将数组构造成UITableView?,iphone,objective-c,xcode,nsarray,Iphone,Objective C,Xcode,Nsarray,我有一个以下格式的数组: [NSArray arrayWithObjects: [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil], [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil], [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil], [NSAr

我有一个以下格式的数组:

[NSArray arrayWithObjects:
 [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil],
 [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil],
 [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil],
 [NSArray arrayWithObjects:@"number",@"name",@"date",@"about",nil],
 nil];
我想构造这些数据以加载到我的tableView中


tableview的每一行应该对应于数组的每一行,然后每个单元格的标题应该对应于名称的子数组objectAtIndex 2。

假设您的数组名为
myData

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
  // Return the number of sections.
  return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  // Return the number of rows in the section.
  return [myData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"Cell";

  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
  }

  // Configure the cell...
  NSArray *obj = [myData objectAtIndex:indexPath.row];
  cell.textLabel.text = (NSString*)[obj objectAtIndex:1]; //note: 0=>number; 1=>name,..

  return cell;
}

为了便于重用,我建议用NSDictionary替换子数组,这样您就可以通过调用
[dict objectForKey:@“name”]

来获取名称。在我看来,这段代码已经是
UITableView的“结构化”代码。您是否正在寻找实现创建
UITableViewCell
s的代码?看起来您这样做的方式不对。。。我想,您需要更具体地说明如何显示tableview,以便设置单元格。类似cell.textlabel.text=[array object at what?]],因为它是数组中的数组。