0

After a bit of bungling I have added a reveal view controller to my app but now it doesn't seem to be loading the data.

I can't see where my changes would have affected that aspect of the app.

in didFinishLaunchingWithOptions I changed

STRTableViewController *tableViewController = [(UINavigationController *)self.window.rootViewController viewControllers][0];
self.delegate = tableViewController;

to the following since the rootViewController is no longer the table view:

// in .m interface 
@property (nonatomic, strong) STRTableViewController *tableViewController; 
...
// in didFinishLaunchingWithOptions
self.tableViewController = [[STRTableViewController alloc] init];
self.delegate = self.tableViewController;

and then (also in AppDelegate) I'm calling a tableViewController method to fetch and load the table data with

- (void)loadTableViewData
{
   [self.tableViewController loadTableData]
}

Also, a bit more info. On first launch, the app loads some dummy data and goes through a short tutorial. At the end of the tutorial the app requests location services and then loads the actual data in the table based on if the user accepts or uses reverse geolocation instead. The dummy data loads for the tutorial but the actual data does not.

Both were loading in the table view perfectly fine before adding the reveal VC so I'm not sure why this would change with the small change I made here.

Any suggestions would be greatly appreciated.

Thanks!

Christian
  • 336
  • 1
  • 4
  • 16
  • Do you still have a STRTableViewController in the storyboard (assuming that you're using one)? If so, you're just creating a new instance with alloc init, not getting the one you already have. – rdelmar Mar 31 '14 at 22:30
  • @rdelmar Yes, it's still in the storyboard. Okay, that makes sense though. And I just ran it again and I was wrong (I'll edit the question shortly) about how the logs are showing the data. They aren't. I was looking at the log for the previous (dummy) data. – Christian Mar 31 '14 at 22:34
  • You need to get the proper reference to the STRTableViewController -- is it one of the controllers in the SWRevealViewController? – rdelmar Mar 31 '14 at 22:39
  • I don't think this is the problem, but when you want a view from the storyboard use [`instantiateViewControllerWithIdentifier:`](https://developer.apple.com/library/ios/documentation/uikit/reference/UIStoryboard_Class/Reference/Reference.html#//apple_ref/occ/instm/UIStoryboard/instantiateInitialViewController) instead of `[[STRTableViewController alloc] init]` – mrosales Mar 31 '14 at 22:42
  • Using alloc init, none of your custom cells would get registered. – mrosales Mar 31 '14 at 22:43
  • @rdelmar Before I added the reveal controller it went navigation controller --> SRTTableViewController --> SRTDetailViewController. The navigation controller being the initial view controller. Now the initial view controller is SWRevealViewController, which splits to what I originally had, and one other view. So I guess I should be calling the tableviewcontroller from AppDelegate differently? – Christian Mar 31 '14 at 22:45
  • Yes you should. I haven't used an SWRevealViewController, so I don't know specifically how to do that, but I assume you would have to use its frontViewController, rearViewController, or rightViewController properties (wherever your STRTableViewController is) to access it. – rdelmar Mar 31 '14 at 22:47

0 Answers0