Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *CellIdentifier = @"Cell";
- BMOptionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- cell.cellSwitch.UDKey = [(BMSettings *)[tableCellArray objectAtIndex:indexPath.row] SKey];
- [cell.cellSwitch addTarget:self action:@selector(switchUD:) forControlEvents:UIControlEventValueChanged];
- // Display cell in the table cell
- BMOptionCell *setting = [tableCellArray objectAtIndex:indexPath.row];
- cell.cellLabel.text = setting.name;
- NSUserDefaults *uDefaults = [NSUserDefaults standardUserDefaults];
- NSLog(@"%@ is the cell.cellSwitch.UDKey String", cell.cellSwitch.UDKey);
- if ([[uDefaults stringForKey:cell.cellSwitch.UDKey] isEqualToString:@"ON"]) {
- NSLog(@"State is ON in this NSUserDefaults");
- cell.cellSwitch.on = YES;
- }
- else if ([[uDefaults stringForKey:cell.cellSwitch.UDKey] isEqualToString:@"OFF"]) {
- NSLog(@"State is OFF in this NSUserDefaults");
- cell.cellSwitch.on = NO;
- }
- else {
- NSLog(@"Something went wrong with setting the switch");
- }
- // Assign our own background image for the cell
- UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];
- UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
- cellBackgroundView.image = background;
- cell.backgroundView = cellBackgroundView;
- cell.cellView.backgroundColor = [UIColor colorWithPatternImage:background];
- cell.infoView.frame = CGRectMake(cell.infoView.frame.origin.x, cell.infoView.frame.origin.y, cell.infoView.frame.size.width, 0);
- return cell;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement