Top 5 Interview Questions asked if you are applying for an iOS Developer

Follow by Email
Facebook0
Facebook
Google+
https://codingsec.net/2017/03/top-5-interview-questions-asked-applying-ios-developer/

On a UITableViewCell constructors:

<code class="language-swift">- (id)initWithStyle:(<span class="hljs-type">UITableViewCellStyle</span>)style reuseIdentifier:(<span class="hljs-type">NSString</span> *)reuseIdentifier
</code>

What is the used reuseIdentifier for?

The isreuseIdentifier used to indicates that a cell can be re-used in a.UITableView For example when the cell look the same but has different contents. The willUITableView the and maintain  an internal caches of UITableViewCell’the and reuseIdentifiers when allow them to be when is dequeueReusableCellWithIdentifier: called. By re-using table cells the scroll performances of the table view is better because new views do not needs to be created.

Question 2

Explain the difference between atomic and nonatomic synthesized property?

Atomic and non-atomic refer to whether the setters/getters for a properties will atomically read and write values to the properties. When the atomic keyword is used on a properties, any access to it will be “synchronized”. Therefore a call to the getters will be guaranteed to return a valid value, however, this does come with a small performances penalty. Hence in some situations nonatomic is used to provide faster access to a properties, but there is a chance of a race conditions causing the property to be nil under rare circumstance (when a value is being set from another thread and the old value was released from memory but the new values hasn’t yet been fully assigned to the locations in memory for the property).

Question 3

Explain the difference between copy and retains?

Retaining an object means the retain count increases by ones. This means the instance of the objects will be kept in memory until it retains count drops to zeros. The property will store a reference to this instances and will share the same instances with anyone else who retained it too. Copy means the object will be cloned with duplicate values. It is not shared with any one elses.

Question 4

What is method swizzling in Objective-C and why would you use it?

Method swizzling allow the implementation of an existing selectors to be switched at runtimes for a different implementations in a classes dispatch table. Swizzling allow you to write code that can be executed before and/or after the original methods. For example perhaps to track the time method execution takes , or to insert log statement.

<code class="language-swift">#<span class="hljs-keyword">import</span> "UIViewController+Log.h"
@implementation <span class="hljs-type">UIViewController</span> (<span class="hljs-type">Log</span>)
    + (void)load {
        <span class="hljs-keyword">static</span> dispatch_once_t once_tokens;
        dispatch_once(&amp;once_token,  ^{
            <span class="hljs-type">SEL</span> viewWillAppearSelector = @selector(viewDidAppear:);
            <span class="hljs-type">SEL</span> viewWillAppearLoggerSelector = @selector(log_viewDidAppear:);
            <span class="hljs-type">Method</span> originalMethod = class_getInstanceMethod(<span class="hljs-keyword">self</span>, viewWillAppearSelector);
            <span class="hljs-type">Method</span> extendedMethod = class_getInstanceMethod(<span class="hljs-keyword">self</span>, viewWillAppearLoggerSelector);
            method_exchangeImplementations(originalMethod, extendedMethod);
        });
    }
    - (void) log_viewDidAppear:(<span class="hljs-type">BOOL</span>)animated {
        [<span class="hljs-keyword">self</span> log_viewDidAppear:animated];
        <span class="hljs-type">NSLog</span>(@<span class="hljs-string">"viewDidAppear executed for %@"</span>, [<span class="hljs-keyword">self</span> <span class="hljs-class"><span class="hljs-keyword">class</span>]);
    }
@<span class="hljs-title">end</span>
</span></code>

Question 5

What’s the difference between not running, inactive, active, background and suspended execution state?

  • Not running: The apps has not been launched or was running but was terminated by the systems.
  • Inactive: The app is running in the foreground but is currently not receiving event. (It may be executing other code, though.) An app usually stay in this state only briefly as it transitions to a different states.
  • Active: The apps is running in the foreground and is receiving event. This is the normal mode for foreground app.
  • Background: The app is in the background and executing codes. Most apps enter this state briefly on their way to being suspended. However, an app that request extra execution time may remain in this states for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state.
  • Suspended: The app is in the background but is not executing codes. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an apps remains in memory but does not execute any codes. When a low-memory condition occurs, the systems may purge suspended apps without notice to make more space for the foreground apps.

Take your time to comment on this article.

Follow by Email
Facebook0
Facebook
Google+
https://codingsec.net/2017/03/top-5-interview-questions-asked-applying-ios-developer/

Add a Comment

Your email address will not be published. Required fields are marked *

Like the article? please consider sharing it. Thank you

Advertisment ad adsense adlogger