multiple didSelectRowAtIndexPath (Multiple datasources)

Discussion in 'iOS Programming' started by ljg93, Aug 29, 2011.

  1. ljg93 macrumors member

    Joined:
    Mar 13, 2011
    #1
    Hello I have a applications set up like the Luxor app on the app store. I have three tableviews that a user can scroll through the toolbar to the desired one they wish.

    One table is set up on interface builder and the other two I made custom data sources and delegates within NSO object files. So I have a Settings View Controller (where one table is set up in interface builder and the other two tables call their data source and delegates) and then a CustomDataSource.h/.m
    and TwoCustomDataSource.h/m

    I am trying to get the didSelectRowAtIndexPath methods to work on the custom data source files. I am having trouble with this line of code
    Code:
       [[self navigationController] pushViewController:viewController
                                                   animated:YES]; 
    It tells me that the the property navigationController is not there. I have the same code used on the settingsTableViewController though.

    I tried to make my own navigation controller and do something like

    [navController] pushviewController etc and it complies but when i click on the cell of the table view, nothing happens..

    Please help me out Thanks!
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Well, in your XIB. You have View Controllers, Naviation Controllers, Tabcontrollers.
    You apparently for your first, have used indeed a navigation controller, and for your second, you used a normal View Controller, try looking in there :)
     
  3. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #3
    theres only one view controller for all of it, I am hiding the table views when a user selects a certain button on the toolbar
     
  4. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #4
    multiple table views on one view

    Hello I have three table views on one view that hide and appear when a user touches a tab on the toolbar (NOT TAB BAR).

    I am trying to get each cell to go to a specific nib when a row is selected.

    For my first tabe which is made in IB it works fine, but the other two tables which are created in code and have outside files as their datasource and delegate do not.

    Any ideas?

    each delegate for each table all has the following code for the didselectrowatindexpath

    Code:
    
    	[tableView deselectRowAtIndexPath:indexPath animated:YES];
    	NSMutableString *workoutName = [NSMutableString string];
    	[workoutName setString:[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]];
    	[workoutName replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, [workoutName length])];
    	[workoutName appendFormat:@"ViewController"];
    	
    	id newViewController = [[objc_getClass([workoutName cStringUsingEncoding:NSUTF8StringEncoding]) alloc] init];
    	[self.navigationController pushViewController:newViewController animated:YES];
    		NSLog(@"<<< Leaving %s >>>", __PRETTY_FUNCTION__);
    
    
    Also, do the two data sources for the two table views created in code need to be NSObjects or viewcontrollers? When they are NSObjects the
    Code:
    	[self.navigationController pushViewController:newViewController animated:YES];
    
    does not work because it is not a property of NSObject.


    PLEASE HELP ME OUT!!!!!!
     
  5. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #5
    THESE are some screenshots
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      134.4 KB
      Views:
      51
    • 2.jpg
      2.jpg
      File size:
      130.5 KB
      Views:
      54
    • 3.jpg
      3.jpg
      File size:
      127 KB
      Views:
      56
    • 4.png
      4.png
      File size:
      309.1 KB
      Views:
      52
  6. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #6
    Didn't you read what I said?
    I'm sorry. But you are trying to do a [self navigationController].
    you think it appears there magically? You have to tell your super view it's a navigationcontroller (so inside your XIB, it has to say Navigation Controller, or you will never be able to PUSH onto your "non-existing" navigation controller.
     
  7. jnoxx, Aug 30, 2011
    Last edited by a moderator: Aug 31, 2011

    jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #7
    You are in way above your head.
    IN my opinion, you just picked up pieces of code on the internet, trying to sell it as an app, but have no idea what you started. If you don't understand the concept of the basics. then I think it's time to hit the books and redo some work.

    I think you are doing some pretty weird ass code. And you need to learn to use the debugger, to help you out
     
  8. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #8
    navigationController is a property of UIViewController. If you are calling [self navigationController] from a class that is not a subclass of UIViewController, you will get the error you are seeing.
     
  9. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #9
    it actually does say navigation controller. In the xib. if you took a look at the screen shot.

    And I did resolve the conflict all I did was set the delegate of the other two table views to the same as the settings but changed the data source.
     

Share This Page