Search Posts in my Blog

Monday 9 July 2012

iOS Interview Questions - Part 1

I’ve been interviewing alot of people recently for iPhone and iPad developer positions. Asides from algorithm runtime problems, I ask some general iOS questions. So being the kind person I am posting some questions based on difficulty and expected answers.






BEGINNER
  • Q: How would you create your own custom view?
    A: Subclass the UIView class.

  • Q: Whats fast enumeration?
    A: Fast enumeration is a language feature that allows you to enumerate over the contents of a collection. (Your code will also run faster because the internal implementation reduces message send overhead and increases pipelining potential.)

  • Q: Whats a struct?
    A: A struct is a special C data type that encapsulates other pieces of data into a single cohesive unit. Like an object, but built into C.

  • Q: Whats the difference between a NSArray and a NSMutableArray?
    A: A NSArray’s contents can not be modified once it’s been created whereas a NSMutableArray can be modified as needed, i.e items can be added/removed from it.

  • Q: Explain retain counts.
    A: Retain counts are the way in which memory is managed in Objective-C. When you create an object, it has a retain count of 1. When you send an object a retain message, its retain count is incremented by 1.
    When you send an object a release message, its retain count is decremented by 1. When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. If an object’s retain count is reduced to 0, it is deallocated.

  • Q: Whats the difference between frame and bounds?
    A: The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.
    The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

  • Q: Is a delegate retained?
    A: No, the delegate is never retained! Ever!

INTERMEDIATE
  • Q: If I call performSelector:withObject:afterDelay: – is the object retained?
    A: Yes the object is retained. It creates a timer that calls a selector on the current threads run loop. It may not be 100% precise time-wise as it attempts to dequeue the message from the run loop and perform the selector.

  • Q: Can you explain what happens when you call autorelease on an object?
    A: When you send an object a autorelease message, its retain count is decremented by 1 at some stage in the future. The object is added to an autorelease pool on the current thread. The main thread loop creates an autorelease pool at the beginning of the function, and release it at the end. This establishes a pool for the lifetime of the task. However, this also means that any autoreleased objects created during the lifetime of the task are not disposed of until the task completes. This may lead to the task’s memory footprint increasing unnecessarily. You can also consider creating pools with a narrower scope or use NSOperationQueue with it’s own autorelease pool. (Also important – You only release or autorelease objects you own.)

  • Q: Whats the NSCoder class used for?
    A: NSCoder is an abstractClass which represents a stream of data. They are used in Archiving and Unarchiving objects. NSCoder objects are usually used in a method that is being implemented so that the class conforms to the protocol. (which has something like encodeObject and decodeObject methods in them).

  • Q: Whats an NSOperationQueue and how/would you use it?
    A: The NSOperationQueue class regulates the execution of a set of NSOperation objects. An operation queue is generally used to perform some asynchronous operations on a background thread so as not to block the main thread.

  • Q: Explain the correct way to manage Outlets memory
    A: Create them as properties in the header that are retained. In the viewDidUnload set the outlets to nil(i.e self.outlet = nil). Finally in dealloc make sure to release the outlet.

ADVANCED
  • Q: Is the delegate for a CAAnimation retained?
    A: Yes it is!! This is one of the rare exceptions to memory management rules.

  • Q: What happens when the following code executes?
    1Ball *ball = [[[[Ball alloc] init] autorelease] autorelease];
    A: It will crash because it’s added twice to the autorelease pool and when it it dequeued the autorelease pool calls release more than once.


  • Q: Outline the class hierarchy for a UIButton until NSObject.
    A: UIButton inherits from UIControl, UIControl inherits from UIView, UIView inherits from UIResponder, UIResponder inherits from the root class NSObject

  • Q: Explain the difference between NSOperationQueue concurrent and non-concurrent.
    A: In the context of an NSOperation object, which runs in an NSOperationQueue, the terms concurrent and non-concurrent do not necessarily refer to the side-by-side execution of threads. Instead, a non-concurrent operation is one that executes using the environment that is provided for it while a concurrent operation is responsible for setting up its own execution environment.

  • Q: Implement your own synthesized methods for the property NSString *title.
    A: Well you would want to implement the getter and setter for the title object. Something like this:
    1- (NSString*) title {
    2  return title;
    3}
    4- (void) setTitle: (NSString*) newTitle {
    5 if (newTitle != title) {
    6     [title release];
    7     title = [newTitle retain]; // Or copy, depending on your needs.
    8 }
    9}

  • Q: Implement the following methods: retain, release, autorelease.
    A:
    01-(id)retain {
    02  NSIncrementExtraRefCount(self);
    03
    04  return self;
    05}
    06
    07-(void)release {
    08
    09  if(NSDecrementExtraRefCountWasZero(self)) {
    10    NSDeallocateObject(self);
    11  }
    12}
    13
    14-(id)autorelease {
    15  // Add the object to the autorelease pool
    16  [NSAutoreleasePool addObject:self];
    17
    18  return self;
    19}

Hopefully some of these questions will help someone get a job! :)

58 comments:

  1. These are awesome! Thanks!!! Not just for people looking for a job, but for those of us new to iOS development! I just wish I'd found your site two months ago!!!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

  3. I was looking about the Oracle Training in Chennai for something like this,Thank you for posting the great content..I found it quiet interesting, hopefully you will keep posting such blogs…
    Greens Technologies In Chennai

    ReplyDelete


  4. I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Greens Technologies In Chennai

    ReplyDelete
  5. let's Jump Start Your Career & Get Ahead. Choose sas training method that works for you. This course is designed for professionals looking to move to a role as a business analyst, and students looking to pursue business analytics as a career. SAS Training in Chennai

    ReplyDelete
  6. The best kits online trainings,thanks for sharing this useful information.

    Oracle Golden Gate

    Ruby On Rails

    SAP XI

    ReplyDelete
  7. fantastic presentation .We are charging very competitive in the market which helps to bring more Microstrategy professionals into this market. may update this blog microstrategy Training in Chennai

    ReplyDelete
  8. i gain the knowledge of Java programs easy to add functionalities play online games, chating with others and industry oriented coaching available from greens technology chennai in Adyar may visit. core java Training in Chennai which No1: Greens Technologies in Chennai

    ReplyDelete
  9. It's really helpful for me to understand. Thanks.If anyone wants to Learn visit this page Spring Training in Chennai

    ReplyDelete
  10. if learned in this site.what are the tools using in sql server environment and in warehousing have the solution thank .. Msbi Training in Chennai

    ReplyDelete
  11. if i share this blog weblogic Server Training in Chennai aims to teach professionals and beginners to have perfect solution of their learning needs in server technologies. weblogic server Training in Chennai

    ReplyDelete
  12. nice post and site, good work! This article is well written and quite informative. More articles should be written and you have just found a follower.and more visit
    sas online training

    ReplyDelete
  13. TNPSC 813 Village Administrative Officer Recruitment 2015

    Thanks for sharing useful information and it is very helpful...................

    ReplyDelete
  14. GSSSB 2480 Revenue Talati Bharti Recruitment 2016

    Its really great information i am thank full to this website..........

    ReplyDelete
  15. Assam 2564 Police Constable Recruitment 2016 Apply Online



    I want to thank you for this informative read; I really appreciate sharing this great............

    ReplyDelete
  16. Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
    Informatica Training In Chennai
    Hadoop Training In Chennai
    Oracle Training In Chennai
    SAS Training In Chennai

    ReplyDelete
  17. I just see the post i am so happy to the communication science post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be replay for your great thinks and I hope you post again soon...
    IOS Training in Chennai

    ReplyDelete
  18. Super questions about ISO and this questions has helped our students to clear the interview.thanks for sharing the information and we also provide training for SQl and PLSQL.

    Oracle SQL Frequently Asked Questions

    ReplyDelete
  19. This post is much helpful for us. This is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
    Web Designing Course in chennai
    Best Web Designing Institute in Chennai
    Best web designing course in chennai
    web design classes
    Web Designing Training Centers in Chennai
    web design training chennai

    ReplyDelete
  20. This blog is more effective and it is very much useful for me.
    we need more information please keep update more.

    Salesforce Training in Saidapet
    Salesforce Training in Ashok Nagar
    Salesforce Training in Nungambakkam

    ReplyDelete
  21. This software of QuickBooks Payroll Support Phone Number is sold with various versions and sub versions. Online Payroll and Payroll for Desktop is the two major versions and they are further bifurcated into sub versions. Enhanced Payroll

    ReplyDelete
  22. QuickBooks Support Number We now have trained staff to soft your issue. Sometimes errors may possibly also happen as a consequence of some small mistakes.

    ReplyDelete
  23. It Provides Necessary Features In Real Time For The Enterprises. Since The Software Runs On Desktop And Laptop Devices, It Truly Is Prone To Get Errors And Technical Glitches. But also for Such Cases, QuickBooks Enterprise Techical Support Number Is Present Which Enables A Person To Acquire His Errors Fixed.

    ReplyDelete
  24. QuickBooks has been recognised world wide as the utmost effective and useful accounting software. QuickBooks Tech Support Number executives that really work with you on QuickBooks Support contact number are responsible to manage every Quickbook technical issue that produces in QuickBooks software.

    ReplyDelete
  25. We provide Quickbooks Payroll tech support team in terms of customers who find QuickBooks Payroll hard to use. As QuickBooks Online Payroll Contact Number we make use of the responsibility of resolving all of the issues that hinder the performance regarding the exuberant software.

    ReplyDelete
  26. A tiny grouping of execs are capable of you manually due to they’re absolute to offer the standard services. So, in the event that you face any issue and your package you don’t need to go anywhere except us. You simply need certainly to build a straightforward charge less call on our QuickBooks Support Phone Number variety and rest leave on united states of america country.

    ReplyDelete
  27. QuickBooks Enterprise offers useful features making it more reliable along with efficient. You are able to run your business smoothly with great ease and flexibility by using this specialized accounting software. This is one way you can save your precious time & money using intuit enterprise support. If you are a QuickBooks user and facing any issue regarding this software then call on the QuickBooks Enterprise Tech Support Number.

    ReplyDelete
  28. They move heaven and earth to provide you with the most effective solution they can. QuickBooks Enterprise Support Number customer service executives have a great deal of experience and they are sharp along side smart to find out the particular cause and optimal solution of each error that you may face.

    ReplyDelete
  29. Our dedicated team is sure to you. They have been surely working at any hour to aid and make suggestions in the event that you run into any QuickBooks Tech Support Phone Number error/s. Our QuickBooks Support team surely have in-depth knowledge in connection with issues and problems of QuickBooks.

    ReplyDelete
  30. QuickBooks Tech Support Number toll free Number advisors are certified Pro-advisors’ and it has forte in furnishing any kind of technical issues for QuickBooks. These are typically expert and certified technicians of their domains like QuickBooks accounting,QuickBooks Payroll, Point of Sales, QuickBooks Merchant Services and Inventory issues to provide 24/7 service to your esteemed customers. QuickBooks payroll Services provide approaches to all your valuable QuickBooks problem and in addition assists in identifying the errors with QuickBooks data files and diagnose them thoroughly before resolving these issues.

    ReplyDelete
  31. The support specialist will identify the difficulty. The deep real cause is likely to be found out. All the clients are extremely satisfied with us. We have many businessmen who burn off our QuickBooks Support Phone Number service. It is simple to come and discover the best service to meet your needs.

    ReplyDelete
  32. The technical Quickbooks Support Number teams who work night and day to eliminate QuickBooks related queries are trained to tune in to the errors, bugs, and glitches that are reported by a user and then derive possible approaches to clear them.

    ReplyDelete
  33. Support For QuickBooks software is helpful for managing the work flow flawless and smooth by prints the payroll components and exchange report are necessary for the modern bookkeepers etc. It is according to application or the cloud based service. Its versions such as:, Payroll, Contractor , Enterprises and Pro Advisor which helps the countless small company world wide .

    ReplyDelete
  34. The most common errors faced by the QuickBooks users is unknown errors thrown by QuickBooks software at the time of software update. To help you to correct the problem, you need to look at your internet and firewall setting, internet browser setting and system time and date setting you can simply contact us at QuickBooks Tech Support Phone Number for instant assistance in QB issues.

    ReplyDelete
  35. QuickBooks is rated business accounting software plus the minute query or issue troubling you don't panic, call the QuicKbooks Customer Support Number. The Intuit certified technician called Proadviors will help & help you to sort out any errors , problem .

    ReplyDelete
  36. It is terribly frustrating, to say the smallest amount once you face one particular error. Errors hamper the work pace however additionally disturb your mental peace. Our QuickBooks Support Phone Number take all the errors terribly seriously and that they will fix all of the errors.

    ReplyDelete
  37. We suggest you to definitely join our services just giving ring at toll-free QuickBooks Enterprise Support Phone Number make it possible for you to fix registration, installation, import expert and lots of other related issues into the enterprise version.

    ReplyDelete
  38. Our QuickBooks Technical Support is obtainable for 24*7: Call @ QuickBooks Technical Support contact number any time Take delight in with an array of outshined customer service services for QuickBooks via quickbooks technical support contact number at any time and from anywhere. It signifies that one can access our tech support for QuickBooks at any moment. Our backing team is dedicated enough to bestow you with end-to-end QuickBooks solutions when you desire to procure them for every single QuickBooks Support Phone Number.

    ReplyDelete
  39. Live Chat support: In the event that customer goes to the QuickBooks Support Phone Number site, there was a live chat feature, which may be helpful as he needs immediate answers to questions.

    ReplyDelete

  40. QuickBooks Support Phone Number has been developing constructive multiple versions of QuickBooks that shall meet up with your business purpose in one single way or any other. Their widely accessible accounting software versions and packages are unique from 1 another and so they may be chosen based on your online business type and workflow.

    ReplyDelete
  41. Runtime Error 9999 happens when QuickBooks fails or crashes whilst it’s running, hence its name. It doesn’t necessarily mean that the code was corrupt in some way, but just that it did not work during its run-time. If you would like to learn How To Fix Quickbooks Error 9999, you can continue reading this blog.

    ReplyDelete
  42. Trade Stocks, Forex, And Bitcoin Anywhere In The World:exness login Is The Leading Provider Of Software That Allows You To Trade On Your Own Terms. Whether You Are Operating In The Forex, Stock, cgin Software And Anonymous Digital Wallet To Connect With The Financial World.: exness login Is A Currency Trading Company That Allows You To Trade Stocks, Forex, And Cryptocurrency.

    ReplyDelete
  43. Nice Topics.. Read My Review Of An Online Cfd Trading Broker,FBS With A Focus On Their Platform And Customer Support Services. I Have Been Using Them For Over A Year And This Is My Honest, Unbiased Review.

    ReplyDelete
  44. Very informative blog . But i also want the world to know There is one company in my mind, its name is AFM Logistics pvt Ltd .It gives best quality logistics service ,ie is AFM Logistics Pvt Ltd is an international freight forwarding and customs clearing company established in Delhi. The company was constituted in 2012 and is indulged in providing complete logistics solution. The company has its own setup and wide network of agents throughout the world. International Logistics Companies In India . They are the best air cargo and ocean freight forwarding company in Delhi, India. AFM Logistics Pvt Ltd has been working as Import and Export Agent in India since 2012. They have been providing personal baggage shipping services in India for a very long time.
    9050025388

    ReplyDelete