Programmatic vs Drag n Drop Approach in iOS Application Development

This blog is for iOS developers looking for making their projects reusable. There are few lines of code, which is given in Swift 3.

If you are an iOS developer, you often come across a situation when you can design the application with Interface builder with dragging and dropping components or designing those components using Swift.

If you are new to iOS development and you have gone through several tutorials, you would have seen those tutorials would be teaching you how to drag drop an element, make connections to the Swift files and go along. But doing that for 100% of the application would not be a good practice.


Your application should be reusable. By reusable I mean, you should be able to use some aspects of the application just by importing some files directly into another application.

That saves a lot of Development as well as Testing hours.

For example: The Login View can be reused in multiple applications requiring that functionality.


Using segues to connect 2 view controllers can be avoided. Whenever you want to switch to the next view controller, Navigation controller can be used. Xcode 8 gives you an option to add a Storyboard ID and Restoration ID to the view controllers. Add an identifier to it, by selecting the View Controller in main.storyboard, going to the identity inspector.

Use the following code to navigate.

  1. let destViewController : UIViewController = self.storyboard!.instantiateViewController(withIdentifier: “your_viewcontroller_storyboard_id>“)
  2. navigationController!.pushViewController(destViewController, animated: true)


Setting Storyboard ID

Setting Storyboard ID


What do you get from this?

All the View Controllers previously connected through segue are now disconnected in the storyboard and can now be easily copied to another project without any hassles.

Just copy the view controller scene and its relative swift file to the other project.

, , , , , , , , , ,
Previous Post
Top 10 Social Media Failures of 2016
Next Post
How to Trace Your Mails Info through Zapier