を設定する際に問題が発生しUITableView
ます。私はと持ってNSMutableArray
いcustomers
ます。次のようになります。
customer
first letter="A"
customer name="Adwars Inc."
customer
first letter="A"
customer name="Amman Co."
customer
first letter="B"
customer name="Building Inc."
customer
first letter="C"
customer name="Computer Co."
だから私はオブジェクトの顧客を持っています。それは私を各顧客に分けます。そして、私は各オブジェクトにいくつかのキーを持っています。2番目のNSArrayには、顧客データに表示される最初の文字がすべて含まれています。次のようになります。
A
B
C
D
G
J
M
S
Z
正しいセクション数とセクション内の行を取得できましたが、テーブルビューにデータを入力しようとすると、常に次のようになります。
ここに私のコードがあります
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"CustomerCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
for(int i = 0; i < [firstletters count]; i++)
{
if (indexPath.section == i) {
for(int count = 0 ;count < [customers count]; count++)
{
NSString *firstletter;
NSString *key;
key = [firstletters objectAtIndex:indexPath.section];
firstletter = [[customers objectAtIndex:count] objectForKey: @"FirstLetter"];
if ([key isEqualToString:firstletter]) {
cell.textLabel.text = [[customers objectAtIndex:count] objectForKey: @"S_NAME1"];
cell.detailTextLabel.text = [[customers objectAtIndex:count] objectForKey: @"s_town"];
}
}
}
}
return cell;
}
それを機能させるために私は何をしなければなりませんか?