what is wrong with the code, getting weird error

Discussion in 'iOS Programming' started by falseblackbear, Apr 7, 2010.

  1. falseblackbear macrumors newbie

    Joined:
    Apr 6, 2010
    #1
    I am getting error message:
    Redefinition of '[RootViewController tableViewdidSelectRowAtIndexPath:]

    this is my



    Code:
     - (void)viewDidLoad {
        [super viewDidLoad];
    	
    	tableList = [[NSMutableArray alloc] init];
    	[tableList addObject:@"Red Line"];
    	[self setTitle:@"Lines"];
    	 
    
    #pragma mark -
    #pragma mark Table view data source
    
    // Customize the number of sections in the table view.
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1;
    }
    
    
    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
        return [tableList count];
    }
    
    
    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        
        static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
        
    	[cell setText:[[tableList objectAtIndex:indexPath.row] retain]];
    
        return cell;
    }
    
    
    
    // Override to support conditional editing of the table view.
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        // Return NO if you do not want the specified item to be editable.
        if ([[tableList objectAtIndex:indexPath.row] isEqual:@"Red Line"])
    	{
    		secondviewcontrol *second = [[secondviewcontrol alloc] initWithNibName:@"secondviewcontrol.h" bundle:nil];
    		[second setTitle:@"Red Line"];
    		[self.navigationController pushViewController:second animated:YES];
    	}
    
    #pragma mark -
    #pragma mark Table view delegate
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {	
    
    
    
    my error occurs in the last line of code
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    You've defined tableView:didSelectRowAtIndexPath twice, on that last line and then the very next method above it.
     

Share This Page