RyJ
RyJ

Reputation: 4025

iOS: IBOutlet nil in Xcode 6

Using iOS 8 and Xcode 6. I embedded a UIWebView in a controller using a storyboard, and hooked everything up. When I run it, though, the webView is coming up nil. Any thoughts?

enter image description here

Upvotes: 5

Views: 870

Answers (3)

pterry26
pterry26

Reputation: 1240

I encountered this problem myself and finally found a solution: At some point Apple changed the way View Controllers are linked with their xib files. Xcode no longer automatically matches, for example, ViewController.swift and ViewController.xib. Instead you must explicitly specify a nib name in your code. Try calling:

NSBundle.mainBundle().loadNibNamed("ViewController", owner: self, options: nil)

or, in Objective C:

[[NSBundle mainBundle] loadNibNamed:@"ViewController" owner:self options:nil];

in your VC's initializer, before you use any IBOutlets (replacing "ViewController" with the name of your View Controller). This is what finally worked for me (in Swift).

See also:

Are view controllers with nib files broken in ios 8 beta 5?

Swift proper way to load xib file

Upvotes: 0

zshcbka
zshcbka

Reputation: 426

What helped me is this answer #1 here.

  1. Clean project
  2. Close XCode
  3. Delete all contents of ~/Library/Developer/Xcode/DerivedData/
  4. Restart MacOs

Exactly in this order.

Upvotes: 1

ares777
ares777

Reputation: 3628

Modify weak @property for webView.

Upvotes: 0

Related Questions