Sebastian Hubard
Sebastian Hubard

Reputation: 163

Can I connect a button to a struct within a new swift file in xcode?

I want to add a UIButton function to a struct within a supplementary swift file in xcode, but whenever I hold the command button and drag the button to the swift code, nothing appears. I'm very new to xcode so any help explaining how I may deal with this would be greatly appreciated.

Do i have to declare a class first or something?

Thank you

Upvotes: 0

Views: 118

Answers (1)

Lou Franco
Lou Franco

Reputation: 89192

You need to start with a class that inherits from UIViewController.

See: https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ConnectTheUIToCode.html

Upvotes: 1

Related Questions