ios interview questions & answers for experienced developers - way 2 ios - intermediate

7
Your Great Journey Starts here. (m (http:// g/2a/5 (https://plu (http://www.twi (http://www.faceboo WaY 2 iOS (http://way2ios.com/) (http://way2ios.com/feed/ (mailto:[email protected]) (http://in.linkedin.com/pub/krish-g/2a/561 (https://plus.google.com/109473649914154868748/p (http://www.twitter.com/krish_gu (http://www.facebook.com/way iOS Interview Questions & answers for experienced developers This is continuation post for iOS Interview Questions for fresher (http://way2ios.com/development/ios- development-2/ios-interview-questions-with- answers/)‘s.list of iOS interview questions helped you to clear iOS/iPhone interviews *Q: *Q: Explain the options and bars available in xcode 4.x workspace window ? A: (http://way2ios.com/wp-content/uploads/2013/01/Xcode4Workspace.jpg) *Q: *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 Top Posts (http://way2ios.com) Tips & Tricks (http://way2ios.com/category/tips-tricks-2/) Sample code (http://way2ios.com/category/samplecode/) Contact (http://way2ios.com/tech-support/) Development (http://way2ios.com/category/development/) OS (http://way2ios.com/category/os/) Programming (http://way2ios.com/category/refernece/programming/) Reference (http://way2ios.com/category/refernece/) Tech News (http://way2ios.com/category/tech-news/) ww.wpfruits.com/downloads/wp- wp- =way2ios.com) Find us on Facebook Way 2 IOS Like 172 people like Way 2 IOS. Facebook social plugin

Upload: sworna-vidhya-mahadevan

Post on 31-Dec-2015

605 views

Category:

Documents


0 download

DESCRIPTION

mr

TRANSCRIPT

Page 1: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

Your Great Journey Starts here.(mailto:[email protected])(http://in.linkedin.com/pub/krish-

g/2a/561/9b)(https://plus.google.com/109473649914154868748/posts)(http://www.twitter.com/krish_guttha)(http://www.facebook.com/way2ios)

WaY 2 iOS (http://way2ios.com/) (http://way2ios.com/feed/rss/) (mailto:[email protected])

(http://in.linkedin.com/pub/krish-g/2a/561/9b)

(https://plus.google.com/109473649914154868748/posts)

(http://www.twitter.com/krish_guttha)

(http://www.facebook.com/way2ios)

iOS Interview Questions & answers forexperienced developers

This is continuation post for iOS Interview Questionsfor fresher (http://way2ios.com/development/ios-development-2/ios-interview-questions-with-answers/)‘s.list of iOS interview questions helped you to clear iOS/iPhone interviews

*Q:*Q: Explain the options and bars available in xcode 4.xworkspace window ?A:

(http://way2ios.com/wp-content/uploads/2013/01/Xcode4Workspace.jpg)

*Q:*Q: If I call performSelector:withObject:afterDelay: – is theobject retained?A:

Yes, the object is retained. It creates a timer that calls a selector on the current threads run loop. It may not beTop Posts

(http://way2ios.com)

Tips & Tricks (http://way2ios.com/category/tips-tricks-2/)

Sample code (http://way2ios.com/category/samplecode/) Contact (http://way2ios.com/tech-support/)

Development (http://way2ios.com/category/development/) OS (http://way2ios.com/category/os/)

Programming (http://way2ios.com/category/refernece/programming/) Reference (http://way2ios.com/category/refernece/)

Tech News (http://way2ios.com/category/tech-news/)

(http://www.wpfruits.com/downloads/wp-

plugins/wp-

rsss_refs=way2ios.com)

Find us on Facebook

Way 2 IOS

Like

172 people like Way 2 IOS.

Facebook social plugin

Page 2: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

100% precise time-wise as it attempts to dequeue the message fromthe run loop and perform the selector.

*Q:*Q: Can you explain what happens when you callautorelease on an object?A:

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

*Q:*Q: Whats the NSCoder class used for?A:

NSCoder is an abstractClass which represents a stream of data. They are used in Archiving and Unarchivingobjects. NSCoder objects are usually used in a method that is being implemented so that the class conformsto the protocol. (which has something like encodeObject and decodeObject methods in them).

*Q:*Q: Whats an NSOperationQueue and how/would you useit?A:

The NSOperationQueue class regulates the execution of a set of NSOperation objects. An operation queue isgenerally used to perform some asynchronous operations on a background thread so as not to block the mainthread.

*Q:*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.eself.outlet = nil). Finally in dealloc make sure to release the outlet.

iOS interview Questions for Expertlevel

*Q:*Q: What is sandbox?

A:

For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time.A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources,hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandboxdirectory, which acts as the home for the app and its data.

iOS interview Questions withAnswers(http://way2ios.com/development/ios-development-2/ios-interview-questions-with-answers/)

iOS Interview Questions &answers for experienceddevelopers(http://way2ios.com/development/ios-development-2/ios-interview-questions-for-experience/)

iPhone interview questions withanswers part- II(http://way2ios.com/development/ios-development-2/iphone-interview-question-answers/)

What is iBeacons in iOS 7(http://way2ios.com/development/ios-development-2/ibeacons/)

Tags

Android (http://way2ios.com/tag/android/)

Apple(http://way2ios.com/tag/apple/)Applebyte (http://way2ios.com/tag/applebyte/)

AppStore(http://way2ios.com/tag/appstore/)Beta (http://way2ios.com/tag/beta/) developer(http://way2ios.com/tag/developer-2/)Enterprise (http://way2ios.com/tag/enterprise/) Free Wifi(http://way2ios.com/tag/free-wifi/) Google(http://way2ios.com/tag/google/) Host File(http://way2ios.com/tag/host-file/) iBeacons

(http://way2ios.com/tag/ibeacons/) ios(http://way2ios.com/tag/ios/)iOS 6 (http://way2ios.com/tag/ios-6/)ios 7(http://way2ios.com/tag/ios-7/) ios7(http://way2ios.com/tag/ios7/)Ios Interview (http://way2ios.com/tag/ios-interview/) iPa (http://way2ios.com/tag/ipa/) iPad

(http://way2ios.com/tag/ipad/) iPhone(http://way2ios.com/tag/iphone-2/) iPhone 6 (http://way2ios.com/tag/iphone-6/)

iPhone interview(http://way2ios.com/tag/iphone-interview/) iphone unlock(http://way2ios.com/tag/iphone-unlock/)

Page 3: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

To help apps organize their data, each sandbox directory contains several well-known subdirectories forplacing files. Above Figure shows the basic layout of a sandbox directory.

*Q:*Q: Is the delegate for a CAAnimation retained?

A:

Yes it is!! This is one of the rare exceptions to memory management rules.

*Q:*Q: What is dynamicdynamic ?

A:A: You use the @dynamic@dynamic keyword to tell the compiler that you will fulfill the API contract implied by aproperty either by providing method implementations directly or at runtime using other mechanisms suchas dynamic loading of code or dynamic method resolution. It suppresses the warnings that the compilerwould otherwise generate if it can’t find suitable implementations. You should use it only if you know thatthe methods will be available at runtime.

*Q:*Q: What happens when the following code executes?Ball *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 poolcalls release more than once.

*Q:*Q: Explain the difference between NSOperationQueueconcurrent 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-concurrentoperation is one that executes using the environment that is provided for it while a concurrent operation isresponsible for setting up its own execution environment.

*Q:*Q: Implement your own synthesized methods for the

iTunes store (http://way2ios.com/tag/itunes-store/)

Mac(http://way2ios.com/tag/mac-2/) Memory management(http://way2ios.com/tag/memory-management/)

Microsoft(http://way2ios.com/tag/microsoft/)Obj-c (http://way2ios.com/tag/obj-c/) Obj-cInterview (http://way2ios.com/tag/obj-c-interview/) Objective-C(http://way2ios.com/tag/objective-c-2/) Rumors(http://way2ios.com/tag/rumors/)samsung (http://way2ios.com/tag/samsung/)security(http://way2ios.com/tag/security-2/) Support(http://way2ios.com/tag/support/)Surface (http://way2ios.com/tag/surface/) SVN(http://way2ios.com/tag/svn/) URL Scheme(http://way2ios.com/tag/url-scheme/) WWDC

(http://way2ios.com/tag/wwdc/) Xcode(http://way2ios.com/tag/xcode/)You tube (http://way2ios.com/tag/you-tube/)

Page 4: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

property NSString *title.A:

Well you would want to implement the getter and setter for the title object. Something like this: view sourceprint?

- (NSString*) title // Getter method

{

return title;

}

- (void) setTitle: (NSString*) newTitle //Setter method

{

if (newTitle != title)

{

[title release];

title = [newTitle retain]; // Or copy, depending on your needs.

}

}

*Q:*Q: Implement the following methods: retain, release,autorelease.A:

-(id)retain

{

NSIncrementExtraRefCount(self);

return self;

}

-(void)release

{

if(NSDecrementExtraRefCountWasZero(self))

{NSDeallocateObject(self);

}

}

-(id)autorelease

{ // Add the object to the autorelease pool

[NSAutoreleasePool addObject:self];

return self;

}

*Q:*Q: What are all the newly added frameworks iOS 4.3 toiOS 5.0?A:

Accounts CoreBluetooth CoreImage GLKit GSS NewsstandKit Twitter

*Q:*Q: What is Automatic Reference Counting (ARC) ?A:

ARC is a compiler-level feature that simplifies the process of managing the lifetimes of Objective-C objects.Instead of you having to remember when to retain or release an object, ARC evaluates the lifetimerequirements of your objects and automatically inserts the appropriate method calls at compile time.

*Q:*Q: What is the difference between retain & assign?

Page 5: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

Share this: TweetTweet 2 Like 0 2

« iPhone interview questions with answers part- II(http://way2ios.com/development/ios-development-2/iphone-interview-question-answers/)

Rumor: iPhone 6 and iPhone mini(http://way2ios.com/tech-news/apple/rumor-iphone-6-

and-iphone-mini/) »

A:

Assign creates a reference from one object to another without increasing the source’s retain count.

if (_variable != object)

{

[_variable release];

_variable = nil;

_variable = object;

}

Retain creates a reference from one object to another and increases the retain count of the source object.

if (_variable != object)

{

[_variable release];

_variable = nil;

_variable = [object retain];

}

Page : 3(http://way2ios.com/development/ios-

development-2/iphone-2/iphone-interview-question-answers-part-2/)

Let us know these list of iOS interview questions helped you to clear iOS/iPhone interviews.

Share (//pinterest.com/pin/create/button/?url=http%3A%2F%2Fway2ios.com%2Fdevelopment%2Fios-development-2%2Fios-

Page 6: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

3 comments

What's this?ALSO ON WAY 2 IOS

What is iBeacons in iOS 71 comment • a month ago

Ben — Awesome Micro location feature....

Next iPhone might have fingerprints for addedsecurity1 comment • a month ago

Pandu — I believe it's a game changer for Apple

iOS 7’s Activation Lock feature gets approval1 comment • a month ago

Krish — Makes the first impression as moresecure. Lets see how it goes?

Contact for Help or Technical Support1 comment • a month ago

Tom — Gud one Beiners

Leave a message...

BestBest CommunityCommunity ⚙⚙ ⤤⤤ShareShare

Reply

fyell • 15 days ago

I noticed a bug in your code when synthesizing your own getter. You should be returning [[title retain]autorelease] (I'm assuming you're synthesizing a property with a retain attribute since your setter isdoing a retain). Since the setter releases the object, you could possibly run into a situation like this:

NSString* myTitle = self.title;self.title = @"A Different Title";

NSLog(@"myTitle is %@", myTitle); //the line above will crash because the setter released the object myTitle was referencing

△ ▽

Reply

horseshoe7 • 24 days ago

You should really update this article as many of the concepts are out of date. For example, askingquestions about pre-ARC. Plus, you also imply that your expert level questions are things that expertsneed to know. They're not that important.

△ ▽

Reply

Bharat Dodeja • a month ago

Very well explained. Thanks for sharing. △ ▽

Comment feedr Subscribe via email✉

0★

Share ›

Share ›

Share ›

KRISH(http://gravatar.com/cehchowdary)“Knowing is not enough; we must apply.Willing is not enough; we must do.”

View Full Profile →(http://gravatar.com/cehchowdary)

(http://images.apple.com/main/rss/hotnews/hotnews.rss)

Latest Apple News

(http://www.apple.com/hotnews/)

MacBook Air the Ultimate Laptop(http://www.theverge.com/2013/6/17/4436332/macbook-air-review-13-inch-2013) August 9, 2013

Apple Reports Third Quarter Results(http://www.apple.com/pr/library/2013/07/23Apple-Reports-Third-Quarter-Results.html?sr=hotnews.rss) July 23, 2013

Apple Unveils Logic Pro X(http://www.apple.com/logic-pro/?sr=hotnews.rss) July 16, 2013

App Store Marks 5 Years of App-ortunity(http://www.usatoday.com/story/tech/columnist/talkingtech/2013/07/09/5-years-of-apple-apps/2499299/) July 11,2013

Ducati Hits the Road Full Throttle withiPad(http://www.apple.com/ipad/business/profiles/ducati/#video-ducati?sr=hotnews.rss) July 1, 2013

visitors Disclaimer

This website is not owned by, is notlicensed by nor is a subsidiary of Apple Inc.iPhone is a trademark of Apple Inc. Thecontent of this website is not supplied orreviewed by Apple Inc. All articles, images,logos and trademarks in this site areproperty of their respective owners. Pleasefollow this link to read the completedisclaimer(http://way2ios.com/disclaimer/).

(http://www2.clustrmaps.com/counter/maps.php?url=http://way2ios.com)

Page 7: iOS Interview Questions & Answers for Experienced Developers - WaY 2 iOS - Intermediate

CyberChimps(http://cyberchimps.com/) © WaY 2 iOS