Main image of article Interview Qs for Objective-C and Swift

Although developers of iOS apps still need to know Objective-C, they should also learn its appointed successor, Swift, which will certainly enhance their market value in coming years. Swift is easy to learn if you’ve worked with programming languages before, suggested Joe Conway, founder and lead mobile strategist for stable/kernel, a custom software development firm, and co-author of iOS Programming: The Big Nerd Ranch Guide. You may even be able to learn Swift on the job if you make the right case to your employer. “I’d be willing to hire someone who hasn’t written a lot of code in Swift,” he said, “as long as they’ve studied the language and they demonstrate a solid understanding of programming concepts during the interview.” Check out the latest iOS development jobs. Conway asks the following questions to find what he calls “muscle-memory programmers” who have what it takes to master Swift on-the-job: How would you go about structuring an iOS application that you are building from the ground up?

  • What Most People Say: “I’d start with the design and consider how the app needs to look to appeal to the user. For instance, I’d think about how the screens should be organized and where the buttons should go.”
  • What You Should Say: “My top priority is building a highly effective app. Therefore, I’d start by defining all the model objects and focusing on data flow. I’d look at how information populates the model objects and how it returns to the server. And since caching is another important part of building an effective native mobile app, I’d consider how the data caches as it travels back and forth between the server and the app.”
  • Why You Should Say It: Building software that works is a top priority and the biggest challenge for mobile app developers. You can always change a screen layout, but the data model is the foundation for the app. If the data flow isn’t considered from the outset, the app may not work, and you’ll be forced to create workarounds later to improve functionality.

What are some of the major differences between Objective-C and Swift?

  • What Most People Say: “I prefer the look and feel of Swift and I certainly won’t miss Objective-C’s square brackets.”
  • What You Should Say: “While Objective-C is more flexible than Swift, Swift is designed to catch programming errors much earlier. For instance, many errors that would occur at runtime in Objective-C—like sending a message to an object that doesn’t implement it—are now checked at compile-time. Objective-C can accomplish all of the things Swift can, but Swift can do so more safely. Swift supports more programming language features, like optionals, tuples and generics.”
  • Why You Should Say It: The second answer demonstrates greater familiarity with the operational differences between Objective-C and Swift. It’s fairly easy to learn another programming language once you understand its strengths, weaknesses and compatibility with other languages.

How would you convert the codebase of an existing iPhone or iPad app?

  • What Most People Say: “I wouldn’t attempt to convert the code. I’d start over and build a brand new app.”
  • What You Should Say: “I’d break off pieces of the application starting with the view controller code. I’d continue by bridging over each section of the Objective-C code with Swift and testing it thoroughly to make sure that the newly converted code is meeting the structural requirements of the previous code.”
  • Why You Should Say It: Your top priority during migration is to maintain the structural integrity of the app, especially if the architecture is sound. The best way to achieve that is to migrate the code one class at a time.

Explain how Objective-C and Swift treat NULL. What are the differences?

  • What Most People Say: “I’m not sure.”
  • What You Should Say: “In Objective-C, a pointer can always point to nil. Therefore, users of a class or library may not know if they’re using a valid object. In Swift, you have to be explicit about whether an object is there or not. This helps programmers safely handle situations where there is an absence of an object.”
  • Why You Should Say It: There’s a strong distinction between optional types in Swift and simple pointers in Objective-C. In Objective-C, pointers can always be pointed to nil, but in Swift, we must clearly state that a value is optional for it to point to nil. This is one of the most important concepts to master for developers who are looking to add Swift to their repertoire.