Resolved Swift: How do I make UIViewController implement delegate protocol?

Discussion in 'iOS Programming' started by moonman239, Apr 21, 2015.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I'm an Objective-C developer who's decided to use Swift for another project. In Interface Builder, I've set up my view controller to be a delegate for a search bar. Now, I want to know how to make my view controller implement the search bar delegate protocol.

    RESOLVED: A quick Google search revealed this article, which says that to implement a protocol, you just do this:
    Code:
    class ViewController:UIViewController,insert protocol name
    {
    }
    
     
  2. grandM macrumors 6502a

    grandM

    Joined:
    Oct 14, 2013
    #2
    indeed
    implement the required methods in your ViewController and pass the ViewController to the class containing the protocol keyword using prepareForSegue and segue.destinationViewController.delegate = self
     

Share This Page