Editing Button

Hello I am a very new and inexperienced developer and I am trying to border around a button. I'm using the Storyboard and when I used ViewController.swift, I can't make the button a weak var. It is only allowing me to edit the actions. Please help, thank you!

I can't make the button a weak var

What do you mean ? You cannot control-drag the button from Storyboard in the code to create the IBOutlet ?

If so, you have to check that the ViewController in the storyboard has the same class as the class into which you try to create the IBOutlet.

So check in Interface Builder (storyboard):
  • select the viewController in which is the button

  • open the Identity Inspector in the right panel

  • check the class of the ViewController

  • is it the same class as the one in code where you try to create the IBOutlet ?

If no, change the class in Identy inspector.

Another possible reason is that you control-drag the button from IB to the wrong place in the file. It must be inside the class.

Another way to try is to write in code:
Code Block
@IBOutlet weak var theButton : UIButton!

Then
  • open the storyboard in a second pane, next to the code (swift file)

  • drag from the white dot on the left of the IBOutlet declaration top the corresponding button in IB.

If that works, don't forget to close the thread by marking the answer as correct.
If not, please explain better your problem.
Editing Button
 
 
Q