Jones
Jones

Reputation: 375

Uilabel and a Tablecell

A small issue i created a custom UITablecell but in the cell it's need to parse data so i connected IBOutlet UILabel *One; to an UILabel but when i'm doing

One.text = @"Lorem..."; an error show's up i imported the UITablecell.h in mijn viewController.

**Use of undeclared identifier 'One'**

/

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";

       ViewControllerCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {

            NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"ViewControllerCell" owner:nil options:nil];

            for (UIView *view in views) {
                if([view isKindOfClass:[UITableViewCell class]])
                {
                    cell = (ViewControllerCell*)view;
                }


            }

        }
One.text = @"Lorem...";
            return cell;
    }

Upvotes: 0

Views: 135

Answers (2)

Cyrus1
Cyrus1

Reputation: 226

First you have to Typecast the tableViewCell to your Custom Cell.

{
  YourCustomCell *objCustomCell=(YourCustomCell *)[tableView cellForRowAtIndexPath:indexPathForThatRow];
  objCustomCell.One.text=@"YourDesiredstringvalue";
}

Upvotes: 0

Paul.s
Paul.s

Reputation: 38728

In this case your instance of your custom UITableViewCell class will be cell, so you'll need to access it like this

cell.One.text = @"Lorem..";

Upvotes: 1

Related Questions