Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
Hello,

I am getting a no visible interface error in the code below - I have highlighted the line in red. can anybody help ? thanks

regards

Kaps
Code:
//
//  BIDViewController.m
//  cells
//
//  Created by Kapil Kapur on 03/09/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDViewController.h"
#import "BIDNameAndColorCell.h"

@interface BIDViewController ()



@end

@implementation BIDViewController

static NSString *CellTableIdentifier = @"CellTableIdentifier";


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.computers = @[
  @{@"Name" : @"MacBook",@"Color":@"white"},
  @{@"Name" : @"MacBook Pro ",@"Color":@"silver"},
  @{@"Name" : @"iMac",@"Color":@"silver"},
  @{@"Name" : @"MacMini",@"Color":@"silver"},
  @{@"Name" : @"Mac Pro",@"Color":@"silver"}];
    
    
  UITableView *tableView = (id)[self.view viewWithTag:1];
 [COLOR="Red"][B] [tableView registerClass:[BIDNameAndColorCell class]
    forCellReUseIdentifier:CellTableIdentifier];
                      [/B][/COLOR]
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -
#pragma mark Table Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
    return [self.computers count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BIDNameAndColorCell *cell = [tableView dequeueReusableCellWithIdentifier:CellTableIdentifier];
    NSDictionary   *rowData = self.computers[indexPath.row];
    
    cell.name = rowData[@"Name"];
    cell.color = rowData[@"Color"];
    
}



@end
 

xArtx

macrumors 6502a
Mar 30, 2012
764
1
Would that be self.tableView because you created the thing inside another thing?
 

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
Thanks. Are you suggesting something along the lines of:-

Code:
UITableView *tableView = (id)[self.view viewWithTag:1];
  [self.tableView registerClass:[BIDNameAndColorCell class];

as I tried that and it didnt work.

regards

Kaps
 

Tander

macrumors 6502a
Oct 21, 2011
676
1
Johannesburg, South Africa
Thanks. Are you suggesting something along the lines of:-

Code:
UITableView *tableView = (id)[self.view viewWithTag:1];
  [self.tableView registerClass:[BIDNameAndColorCell class];

as I tried that and it didnt work.

regards

Kaps

Warning or error?

That code should work just fine. Email me the project so I can take a quick look.

----------

Would that be self.tableView because you created the thing inside another thing?

No it wouldn't.

Code:
    UITableView [COLOR="DarkOrange"]*tableView[/COLOR] = (id)[self.view viewWithTag:1];
    [[COLOR="DarkOrange"]tableView[/COLOR] registerClass:[GraphViewController class] forCellReuseIdentifier:@"Cell"];

With the above code - the second line is referencing the UITableView *tableView above it.

Using self.tableView would mean there was a
Code:
@property(strong, nonatomic)IBOutlet UITableViewController *tableView
declaration in the header or class extension part of the implementation file.

That's my understanding of it anyway.
 

Tander

macrumors 6502a
Oct 21, 2011
676
1
Johannesburg, South Africa
Replace your code with this:

Code:
    UITableView *tableView = (id)[self.view viewWithTag:1];
         [tableView registerClass:[BIDNameAndColorCell class] forCellReuseIdentifier:CellTableIdentifier];


Let me know if that solves it.
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
Hello,

I am getting a no visible interface error in the code below - I have highlighted the line in red. can anybody help ? thanks

regards

Kaps
Code:
//
//  BIDViewController.m
//  cells
//
//  Created by Kapil Kapur on 03/09/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDViewController.h"
#import "BIDNameAndColorCell.h"

@interface BIDViewController ()



@end

@implementation BIDViewController

static NSString *CellTableIdentifier = @"CellTableIdentifier";


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    self.computers = @[
  @{@"Name" : @"MacBook",@"Color":@"white"},
  @{@"Name" : @"MacBook Pro ",@"Color":@"silver"},
  @{@"Name" : @"iMac",@"Color":@"silver"},
  @{@"Name" : @"MacMini",@"Color":@"silver"},
  @{@"Name" : @"Mac Pro",@"Color":@"silver"}];
    
    
  UITableView *tableView = (id)[self.view viewWithTag:1];
 [COLOR="Red"][B] [tableView registerClass:[BIDNameAndColorCell class]
    forCellReUseIdentifier:CellTableIdentifier];
                      [/B][/COLOR]
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -
#pragma mark Table Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
    return [self.computers count];
}

-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BIDNameAndColorCell *cell = [tableView dequeueReusableCellWithIdentifier:CellTableIdentifier];
    NSDictionary   *rowData = self.computers[indexPath.row];
    
    cell.name = rowData[@"Name"];
    cell.color = rowData[@"Color"];
    
}



@end


The method signature must match exactly or it is a different method. And, joy of joys, C, Objective C, and C++ are all case-senstive. This bites me sometimes too. (C is case sensitive but I'm not case sensitive.)

You are trying to call:

Code:
-[registerClass:forCellReUseIdentifier:]
The correct method name is

Code:
-[registerClass:forCellReuseIdentifier:]
(You have an incorrect
upper case "U". "forCellReUseIdentifier" should be "forCellReuseIdentifier")
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.