2012-10-26 36 views
0

我已经整理SQLite中的名字我的数据:按名称排序sqlite的什么返回联合国numberOfRowsInSection

 char*sql="SELECT* FROM tblcocktail ORDER BY drinkname ;"; 

我不知道如何来显示它在以字母排序表: 请指教:)

-(void)viewDidAppear:(BOOL)animated 
{ 
Cocktails*cock=[[Cocktails alloc]init]; 
_arrcocktail=[cock getallcocktail]; 
[self.tableView reloadData]; 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
// Return the number of sections. 
return [_arr count]; //all the letters 
} 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    //i don't not what to put here so it will show me the right name under the right letter 
} 

回答

0

您可以简单地创建单元格并分配名称。

tableView:cellForRowAtIndexPath:

static NSString *CellIdentifier = @"CellIdentifier"; 

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

// Configure the cell... 

cell.textLabel.text = [_arr objectAtIndex:indexPath.row]; 

return cell; 
} 
+0

,但我需要的数据进行排序的字母 – user1763326

+0

看看这个。 http://stackoverflow.com/questions/4197842/iphone-how-to-use-core-data-in-an-already-created-program –