-(IBAction)btnSaveScore:(id)sender
{
if(!dictWinData)
dictWinData = [[NSMutableDictionary alloc] init];
array = [NSMutableArray arrayWithObjects:txt_EnterName.text,
[NSString stringWithFormat:@"%i",iTap], nil];
int increment = 0;
NSLog(@"array data is:--> %@",array);
for (int intWinData = 1; intWinData < [array count]; intWinData++)
{
[dictWinData setObject:array forKey:[NSString stringWithFormat:@"NameScore%d",increment]];
increment++;
}
}
これは、ゲームの私のスコアを名前で追加するコードです。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [dictWinData 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];
ArrStr = [dictWinData valueForKey:[NSString stringWithFormat:@"NameScore%d",indexPath.row]];
UILabel *lblDayName = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 160, 21)];
lblDayName.text = [ArrStr objectAtIndex:0];
lblDayName.textColor = [UIColor blackColor];
lblDayName.font = [UIFont boldSystemFontOfSize:17.0];
lblDayName.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblDayName];
[lblDayName release];
UILabel *lblLow = [[UILabel alloc] initWithFrame:CGRectMake(180, 50, 40, 21)];
lblLow.text = [ArrStr objectAtIndex:1];
lblLow.textColor = [UIColor blackColor];
lblLow.font = [UIFont boldSystemFontOfSize:17.0];
lblLow.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:lblLow];
[lblLow release];
}
return cell;
}
これはプレーヤーの名前とスコアを保存していますが、毎回テーブルに 1 つのレコードのみを表示します。
リストの最後の上位 10 のスコアを表示する必要があります。
主な問題は、これがすべてのスコアデータを保存および表示していないことです。
この問題を解決するために私を導いてください。
前もって感謝します。