1

I've been struggling to get this to work. I can't seem to get both the slide menu and table view (with data) to work simultaneously. I can only get one or the other.

This issue I believe resides in my AppDelegate. Here's the affected section.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions {

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

UIStoryboard *countryStoryboard = [UIStoryboard storyboardWithName:@"Country" bundle:nil];
UINavigationController *navigationController = [countryStoryboard instantiateInitialViewController];
MetallurgyMasterViewController *countryViewController = (MetallurgyMasterViewController *)navigationController.topViewController;

__managedObjectContext = self.managedObjectContext;
countryViewController.managedObjectContext = self.managedObjectContext;
[Country importDataToMoc:self.managedObjectContext];

self.window.rootViewController = navigationController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

Here's the related section in my TableViewController.

- (NSFetchedResultsController *)fetchedResultsController {
if (_fetchedResultsController != nil)
{
    return _fetchedResultsController;
}

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSLog(@"The value of managedObjectContext is %@", self.managedObjectContext);
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Country" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];

NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                                                      managedObjectContext:self.managedObjectContext 
                                                                        sectionNameKeyPath:@"sectionTitle"
                                                                                 cacheName:@"Country"];
frc.delegate = self;
self.fetchedResultsController = frc;

NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error])
{
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}

return _fetchedResultsController;
}    

In the above setup, my table works fine but I can't seem to call up the slide menu.

If I substitute the following line in my AppDelegate.

UINavigationController *navigationController = [countryStoryboard instantiateInitialViewController];

for

UINavigationController *navigationController = [countryStoryboard instantiateViewControllerWithIdentifier:@"startView"];

and comment out the NSFetchedResultsController method in my TableViewController then the slide menu works fine but the table view isn't populated (I understand why there's no data). If I don't comment it out then managedObject is NIL and it throws an error.

It might be simple but I think I've been looking at this too long.

Mitch Fortier
  • 336
  • 1
  • 3

0 Answers0