में चयनित cheklist पंक्तियों को सहेजें Iam Iphone के लिए बहुत नया है और यह मेरी परियोजना में मेरा आखिरी मॉड्यूल है .. निम्नलिखित कोड chekmark के साथ कई देश चयन के लिए पूरी तरह से काम कर रहा है। मूल रूप से मेरा प्रश्न यह है कि उन चयनित देशों को कैसे सहेजना है और इस दृश्य पर वापस आने पर फिर से चेक मार्क दिखाएं। कृपया मुझे यहाँ मदद ..NSuserdefaults
मेरे didSelectRowAtIndexPath विधि
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
if([selectedCell accessoryType] == UITableViewCellAccessoryNone)
{
[selectedCell setAccessoryType:UITableViewCellAccessoryCheckmark];
[selectedIndexes addObject:[NSNumber numberWithInt:indexPath.row]];
}
else
{
[selectedCell setAccessoryType:UITableViewCellAccessoryNone];
[selectedIndexes removeObject:[NSNumber numberWithInt:indexPath.row]];
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[tableView reloadData];
}
मेरे cellForRowAtIndexPath विधि
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HolidayAppDelegate *delegatObj = (HolidayAppDelegate *)[UIApplication sharedApplication].delegate;
static NSString *CellIdentifier = @"CustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text=[delegatObj.allcountryarray objectAtIndex:indexPath.row];
[cell setAccessoryType:UITableViewCellAccessoryNone];
for (int i = 0; i < selectedIndexes.count; i++)
{
NSUInteger num = [[selectedIndexes objectAtIndex:i] intValue];
if (num == indexPath.row) {
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
break;
}
}
return cell;
}
धन्यवाद