Storyboard UIView Objects Not Instantiating

I am working on a project with Swift and Storyboards. It's a conversion project from a traditional IB and Objective-C project. I am having an issue with a UITableView instantiating when the view is loaded. Let me explain.

The project is a navigation project. Here is an overview of the Storyboard.

The Storyboard's first viewController is HomeViewController and is a landing page that displays general info. The next VC is called FeedViewController shows a number of RSS feeds. You can see an expanded screen shot of the NavigationController, HomeViewController and FeedViewController in the picture below.


My problem is that I can't get the tableView to Instantiate. I first checked to make sure that my tableView was connected as an outlet and that the dataSource and delegate properties were connected. You can see this in the pic below.


In my FeedViewController class I have an Outler property called feedsTableView. You can see the declaration in the code below.


class FeedViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, FLODataHandlerDelegate 
{ 
     var floView : FLOViewController?
     var dataHandler : FLODataHandler?

          var refreshControl : UIRefreshControl? 

     @IBOutlet var feedsTableView: UITableView! 
     @IBOutlet weak var backgroundImage: UIImageView!


In the HomeViewController I have a FeedViewController property that I intend to use to gain access to FeedViewController's feedsTableView.


class HomeViewController: UIViewController, FLODataHandlerDelegate, MFMailComposeViewControllerDelegate 
{
     var feedViewController : FeedViewController? 
     var dataHandler : FLODataHandler?


When HomeViewController's viewDidLoad() method is called I start the dataHandler - which instantiates the FeedViewController - and set it to my FeedViewController property.


override func viewDidLoad() 
{ 
     super.viewDidLoad()
     let recognizer = UISwipeGestureRecognizer(target: self, action: Selector("goToNext")) 
     recognizer.direction = UISwipeGestureRecognizerDirection.Left 
     self.view.addGestureRecognizer(recognizer) 
     self.setUpDataHandler() 
}


setUpDataHandler()


func setUpDataHandler() 
{ 
     let storyboard = UIStoryboard(name: "Main", bundle: nil) 
     let vc = storyboard.instantiateViewControllerWithIdentifier("FeedViewController") as! FeedViewController 
     self.feedViewController = vc 
}


I also have a fail safe that if someone were to go to the FeedViewController before the setUpDataHandler() method is called then I instantiate FeedViewController here as well.


func goToNext() 
{ 
     let feedVC = self.storyboard!.instantiateViewControllerWithIdentifier("FeedViewController") as! FeedViewController 
     self.feedViewController = feedVC 
     self.navigationController!.pushViewController(self.feedViewController!, animated: true) 
}


However the feedsTableView is not getting instantiated. In the viewDidLoad() method of FeedViewController I attempt to add the feedsTableView to a UIRefreshController.


override func viewDidLoad() 
{ 
     super.viewDidLoad() 
     self.refreshControl = UIRefreshControl() 
     self.refreshControl!.addTarget(self, action: "refreshInvoked:state:", forControlEvents: UIControlEvents.ValueChanged) 
     self.feedsTableView.addSubview(self.refreshControl!) 
}


When the app runs I get the following error.


"fatal error: unexpectedly found nil while unwrapping an Optional value"


The image below shows were this is called. It's the viewDidLoad() of the FeedViewController. As you can see in the picture I even tried instantiating the feedsTableView before adding it to the UIRefreshController and I still get the error.



Any help would be greatly appreciated.


Take care,


Jon

Replies

I can't see the screenshots.

I'm sorry but they will not show up. I can answer any questions you have about the screenshots.


Take care,


Jon

Have you checked whether the table view is non-nil in awaikFromNib? Are you sure that the outlet is correct connected?

And are you sure that the table view is nil and not something else?


I assme the screenshots would answer all those questions. 🙂

Thanks for the reply. I changed a fiew things along with the segue. I am not sure why it fixed it but it did. Thanks for the input.


Take care,


Jon

I am a newbie developer. I got an RSS Feed app on Apple's app store. I used the final project on this cool IOS Website as the base of my Project: http://sweettutos.com/2015/03/30/develop-rss-feed-parser-app-in-swift/. I was wondering how to search my RSS feed for the SRC Tag so I can add a picture to each cell for each news story. Here is the link to my app :https://itunes.apple.com/us/app/vi-consortium/id1003059882?ls=1&mt=8.