No visible interface error

Discussion in 'iOS Programming' started by Kapthehat, Sep 4, 2013.

  1. Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    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
    
     
  2. xArtx macrumors 6502a

    Joined:
    Mar 30, 2012
    #2
    Would that be self.tableView because you created the thing inside another thing?
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #3
    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
     
  4. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #4
    Warning or error?

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

    ----------

    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.
     
  5. Tander macrumors 6502a

    Tander

    Joined:
    Oct 21, 2011
    Location:
    Johannesburg, South Africa
    #5
    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.
     
  6. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #6

    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")
     

Share This Page