iOS Interview Questions and Answers 2017 - Swift - Series Overview

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys I'm Sean and I'm an iOS developer here in San Francisco I just recently left my first developer job and now I'm in the market for my second one it's not the end of April in 2017 and I've made the rounds all over town large companies small companies all in all I've done about 15 to 20 interviews that made it to the phone screen or later stage real quick what those stages are typical technical interviews if you're not from New York you'll get a recruiter call which is typically a 1530 minute phone call just to get a feel for you make sure you're not crazy and the second step is a phone screen which is a one-hour call we're going to do some live coding with someone you make it past that then you go on to the big long five to six hour all day on-site interview so backing up I've done about 15 to 20 interviews here around town that have made it to the phone screen stage or later so I feel like I have a pretty good grasp on the type of iOS questions that are being asked at this time so I decided to make a video series sharing this information with you guys now this first video is going to be an overview intro video I'm going to talk about all the subjects but I'm going to stay at a very high level so far looking for is the general idea of what's being asked and then a summary of an answer this video is for you however if you want to deep dive in each one of these topics I'm going to be putting out videos over the next couple weeks they'll dive deeper into these topics so if you're interested in that stay tuned subscribe keep an eye out for more videos coming alright the first topic we're going to discuss is something that was asked in 100% of the interview so make sure you know this and that is automatic reference counting retained cycles memory leaks they're all kind of in the same genre so the gist of automatic reference counting is it keeps track of your strong references to an object and when that count gets to zero it'll automatically deallocate it from memory for you however if you have a retain cycle or two objects have a strong reference to each other it's kind of a never-ending loop and that count will never get to zero that's a call to retain cycle or memory leak and a general quick fix for this is to make one of those strong references a weak reference I'm sure you've seen this in Kosovo versus weak VAR you know whatever the name is so that's what that's doing that's preventing an extra-strong reference from being made so yeah just a quick overview of automatic reference counting retained cycles memory leaks know this cold again it was asked 100% of the time I'll link to a great Apple doc that explains automatic reference counting it's pretty long but if you read through that and you fully understand that you'll be good to go and one last tip if you nail that basic retain cycle memory leak question they're most likely going to ask you the follow-up question which is to explain memory leaks enclosures now that's where weak self and unknown self comes in so make sure you research those as well now the next question that was asking I would say about 80% of the interviews is communication patterns between views and in Swift what they're mainly talking about is delegates versus observers and notifications now the main thing to know here is that delegates is a one-to-one communication like one view is communicating with another view where as observers notifications you can have one observer and then have ten different areas notify that observer throughout your code so it's a one-to-many communication pattern so it's good to know when to use which communication pattern and the pros and cons of each so for example one of the downsides to the observer notification pattern which again is the one-to-many pattern is theoretically you could have 10 to 20 notifications spread out all throughout your code all pointing back to one observer so again you can imagine in a complicated code base you know there could be timing issues it's just it's just hard to keep track of and it can get out of control so just one example the downsides again know the pros and cons of both and when to use each one delegates versus notifications and observers next up we have a pretty basic one and that is what is the lifecycle overview I got asked this about five or six times throughout all the interviews so it's a pretty common question it's good to know so what we're talking about here is viewdidload viewwillappear view will lie out subviews if you did layout subviews and view did appear that's creating the view now getting rid of the view is view will disappear and then view did disappear let's run through each one of those real quick again high level overview viewdidload gets called the very first time the view is loaded into memory and it only gets called once the reason I bring that up is because view will appear which is the next step gets called every time the view appears now an example of this is say you're in a navigation controller a master-detail view and you keep going you know to the detail back to the master back and forth buted low is not going to keep getting called but viewwillappear will keep getting called so if you have something you need to do every time the view appears such as an animation or anything like that you need to do it in viewwillappear not be too low because if you de lausanne unit called once so next is view will out sub views and view did layout sub views now these two are where the view is actually laying out all the sub views the constraints the sizing and everything and finally a view did appear which means the view is completely loaded now on the back side we have view will disappear which you can do stuff right before the view disappears and then finally if you did disappear to let you know the view is gone that's just a quick and dirty overview of the view lifecycle definitely research it some more so the next question is something I got asked a couple times and apparently I didn't learn from the first time I got asked it because I never had a good answer for it and that is what is your favorite Apple framework to work with and what they're asking here is you know D like core location like you I kid you like mapkit in if you do why give specific reasons why you like that API again I never had a good answer for this question so I can't really help you out that much but figure out an API that you like to work with and have good reasons why I got asked this next question a couple times it's a pretty basic one and that's the classic classes versus trucks question when would you use one versus the other explain that classes are a reference type that if you change a property on that class you're actually going to change the reference whereas a struct is a value type what essentially creates a copy of that objects are not overwriting other properties and then there's other issues that if you subclass something you're inheriting everything from that parent class which might be some bloat that you don't necessarily need whereas structure lightweight and clean so make sure you know when to use a class versus Wendi's destruct and the pros and cons between the two I only got asked about this next topic twice so it's not super common but it's still very useful to know and that is filter map and reduce on collections and Swift so filter well for example filter array if you want to filter out all the even numbers in an array you can do that map is if you want to apply like a transform to every object in the array so again the an array of numbers if you want to multiply every number by three you would use map and then reduce the classic example of reduce is summing up the numbers in an array now it's kind of hard to get much deeper than that in a talking example without actually showing you code so I'll save that for when I do a separate video on filter map and reduce later in the series but make sure you study up on this so next up we have testing in it's a big one I got us pretty much every interview if I had experience with testing in fortunately I didn't and I know for a fact that cost me one job and certainly didn't help with any of the others so if you're early in your career you're jr. you've probably skimmed over testing to learn basically Swift in general but it's absolutely something you should focus on and that's actually what I'm doing right now in my downtime doing tutorials trying to figure out how to build testing Suites and some of my existing projects don't overlook this guys it's an easy topic to skim over please don't and the final non coding topic I want to talk about is third-party libraries I got us pretty much all the time what experience I had with third-party libraries like cocoa pods or Carthage or Swift package manager what they're looking for in this question is to see if you have experience using third-party libraries and if you understand the pros and cons to using them at the end of the day that's what a dependency is you're depending on somebody else's code in your project so especially in a language like Swift where it's constantly changing you got to hope the manager of that library is keeping up to date with Swift to keep your project going I mean that's just one example but know the pros cons of third-party libraries and know how to use them alright shifting gears a little bit let's talk about some of the actual coding exercises I had to do now obviously I can't say what company asked what question and these are going to be generalized principles so it's not the exact question I got asked but this should give you some idea of what to expect first up was the most common coding path I got asked to do and that was gesture recognizers which kind of common by surprised because they aren't something I typically use in projects so what we're talking about here is the the tap gesture recognizer the pain and gesture recognizer or the pinch and zoom now in four different phone screens or on-site interviews I got asked to do something with gesture recognizers an example this would be you know on the screen grabbing a file and dragging it to a trash bin just manipulating objects on the screen using a gesture recognizer so don't sleep on this topic there's tons of tutorials out there get some practice from my experience if you interview at a few companies you're almost certainly going to be asked to demonstrate your ability to use gesture recognizers in a UI next is something I surprisingly only got asked to do twice I thought I was going to get asked to do this at basically every interview and that's networking an example of this was I had to authenticate on a server they gave me all the API information the endpoint I needed but essentially I had to build the URL with the proper headers with authorization and make sure the body of the request was complete with the username password etc and had to authenticate on the server and return a token like I said I was very surprised I only had to do this twice because this is a very fundamental cast to iOS development so definitely make sure you practice this make sure you know it I think I just got lucky I only had to do it twice I imagine this is a very common question in interviews some other smaller and common questions I got asked was I got asked to do merge sort and Swift I also got asked to shuffle an array and Swift and then debugging is also another big one I got asked this about three or four times well they'll actually put code in front of you and you have to debug it just by looking at it I mean you can't like run the project and let Xcode yell at you with all the errors you have to find the errors yourself and it's typically the usual suspects look for optionals being forced and wrapped and appropriately look for race conditions in the network calls look for retained cycles memory leaks like we talked about earlier and then look for like UI not being updated on the main thread etc etc it's usually kind of the same thing so if you get a debugging question look for those common issues another type of coding question I got asked more than once was to take a large unit and break it down into smaller units so what I mean by that is let's say you have a hundred thousand seconds and you need to break that down into days hours minutes seconds now the key to these types of questions is the modulo operator that's the percent sign what modulo does is it gives you the remainder left so just for example two modulo five is going to be one because two goes into five evenly twice four and then there's one remainder so one so again 2 modulo 5 is 1 now how you would use this in this time example is let's say you had 64 seconds so you would do 64 modulo 60 because there's 60 seconds in a minute and that will give you a ranger of 4 so you'd have 1 minute and four seconds so that's kind of like the tail end of breaking it down into days hours minutes seconds you would just do that all the way down so the mobile story is no the modulo operator learn it love it do some practice problems I got asked about it a few times and just to kind of wrap up this coding problem section just be really familiar with iterating through for loops and while loops cetera almost every problem has something to do with that and finally I just wanted to mention the take home project now I love these so when you're doing the typical phone screen or on-site coding interview you have somebody looking over your shoulder you have typically a half hour to 45 minutes to do it it's a lot of pressure and it's not how you typically work however the take home project you know you can sit at your desk for a couple hours knock it out do your typical researching that you do I feel like I excel in those so that being said let me just talk real quick about a couple that I had to do so one was basically a mini version of their app I mean it at everything from networking to building a table view to building the UI to a design spec I got handed a sketch file that had the design spec and I had to build exactly to that spec persistence it's an animation even that kid so it just touched on a lot of the core fundamentals that iOS developers have to use I just really enjoyed the project it took me about six hours to do but I learned a lot it was fun so like I said I love these take on projects another one I did that was not so easy and not so fun but a good learning experience was I had to build a basic login flow but it was a 100 percent programmatic UI no storyboards no nothing for auto layout I had to do Auto layout completely encode for me was the first time I had done that because I basically grown up on storyboards so that was challenging and I don't know if I'm a fan of it yet I definitely saw how the other side lives a little bit now a lot of people scoff at the idea of a take home project but I actually love them like I said I feel like I excel at them I look at as a learning experience whether I get the job or not I built something and it's a lot different when you're building something knowing somebody's going to evaluate every line of code you definitely take extra care to make sure everything is perfect about that codebase so that's good practice as well alright so there you have it like I said I've done about 15 to 20 phone screens or on sites in the past two months I've been through the wringer in this whole interview process so I'm sharing my information this is just the overview video I'm going to be releasing new videos in the coming weeks that dives deep into each one of these topics doing some of the coding examples etc so if you think you're going to find those useful go and hit subscribe and keep an eye out in the coming weeks
Info
Channel: Sean Allen
Views: 82,353
Rating: undefined out of 5
Keywords: iOS Interview, iOS Interview Questions, iOS Interview Questions in Swift, Swift, Swift 3, iOS Development, iOS Developer, Learn Swift, Xcode, Swift Tutorial, iOS Tutorial, Swift Interview Questions, Software Interview Questions, Software, Apple, iOS
Id: 56ZO6Gg68tw
Channel Id: undefined
Length: 11min 42sec (702 seconds)
Published: Mon May 01 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.