Loading…

Objective C Interview Questions

Objective C Interview Questions

An ANSI-based version of the standard C programming language, Objective-C is the key programming language used for mobile app development by companies that make apps for OS X and iOS. Objective-C is developed on top of C language by adding Small Talk features that make it an object-based language. It is a superset of C language and provides object-situated features and dynamic runtime.

Development History

Objective-C was created by Tom Love and Brad Cox at their company Stepstone in the early 1980s. Later, in 1988, StepStone have the license for Objective-C to NeXT. NeXT further developed Objective-C for NeXTSTEP OS. Later, Apple took over NeXTSTEP OS for iOS and Mac OS X. Objective-C was not invented by Apple.

Latest Version: Apple released Objective-C 2.0 at the Worldwide Developers Conference in 2006.

Advantages
  • Well-tested and mature language
  • Documented frameworks.
  • Strong online support.
  • Works smoothly with C and C++.
  • Stable language.

Are you for looking for objective c interview questions? As a objective c developer, you would want to know the best possible objective c interview questions and answers or c interview questions and answers objective type that you might be asked in your job Interview.

Have a look at these objective c interview questions for experienced. These objective c interview questions for freshers are designed for developers who are preparing for an Interview.

Last update: 03 Apr 2019, 26 Questions and Answers

Most Frequently Asked Objective C Interview Questions And Answers With Examples:

An ANSI-based version of the standard C programming language, Objective-C is the key programming language used for mobile app development by companies that make apps for OS X and iOS. Objective-C is developed on top of C language by adding Small Talk features that make it an object-based language.

0 0

Objective-C was created by Tom Love and Brad Cox at their company Stepstone in the early 1980s.

0 0

Apple released Objective-C 2.0 at the Worldwide Developers Conference in 2006. It is its latest version.

0 0

A protocol announces a programmatic interface that a class chooses to implement. It enables two classes that are related by inheritance to “talk” with each other in order to accomplish a goal.

0 0

Protocols are of two types - formal and informal.
An extension of the Objective-C language, a formal protocol announces a list of methods that client classes are likely to implement.

An informal protocol is one of the categories on NSObject that makes all objects adopters of the protocol. Implementing methods in an informal protocol is optional.

0 0

#import function ensures a file is included only once so that you do not have a problem with recursive include.
import is a super set of include and it ensures file is included once.

0 0

A category is used to add methods to an existing class. The added methods are usually inherited by subclass and are difficult to differentiate from the original methods at runtime. Categories are used to distribute the implementation of their classes into separate source files.

#import “SystemClass.h”
@interface SystemClass (CategoryName)
    // method declarations
@end

 

0 0

NSMutableArray is the subclass of NSArray and they both manage collections of objects known as arrays. NSArray is responsible for creating static arrays, whereas NSMutableArray is responsible for creating dynamic arrays.

0 1

The object is a collection of as an array or set of Cocoa classes that may include the collection classes. This collection of classes adopts the NSFastEnumeration protocol. This protocol can be used to retrieve elements that are held by an instance by using a syntax that is similar to a standard C for loop.

Look at this instance:
NSArray *anArray = // get an array;
for (id element in anArray)
{
   /* code that acts on the element */
}

0 0

@synthesize creates getter and setter for the variables and allows you to specify attributes for variables. When you @synthesize the property to the variable, you generate getter and setter for that variable.

0 0

This is how you call a function:
[className methodName]
    For announcing methods in same class, use this:
[self methodName]

0 0

The dot syntax is a shortcut for calling getter and setter.

You can use this:
[foo length]
foo.length
are exactly the same, as are:
[foo setLength:5]
foo.length = 5

0 0

NSObject is the root class from which a lot of other classes inherit. When an object encounters another object, it interacts using the basic behavior defined by the NSObject description.

0 0

Atomic is the default behavior that ensures the present process is completed by the CPU.

Non-Atomic is not the default behavior and may result in unexpected behavior.

0 0

GCD refers to GrandcentralDispatch. GCD creates only one thread for executing the blocks and those blocks execute sequentially. The best thing about GCD is that the programmer does not have to create threads or match the number of threads to the available processors.

0 0

KVC stands for Key-Value-Coding. It refers to accessing a property or value using a string.
id someValue = [myObject valueForKeyPath:@”foo.bar.baz”];
Which could be the same as:
id someValue = [[[myObject foo] bar] baz];


KOC stands for Key-Value-Observing. It allows programmers to observe changes in property or value.
In order to observe a property using KVO, you should identify the property with a string. The observable object must be KVC compliant.
[myObject addObserver:self forKeyPath:@”foo.bar.baz” options:0 context:NULL];

0 0

You can dealloc for memory management. Once an object “retainCount” reaches 0, a dealloc message is sent to that object. Never call dealloc on objects unless you call [super dealloc]; around the close of a overridden dealloc.
(void)dealloc
{
   [ivar release]; //Release any retained variables before super dealloc
   [super dealloc]; //Only place in your code you should ever call dealloc
}

0 1

Blocks are language-level features that are added to Objective C, C, and C++. Blocks allow you to create segments of code that can be passed to methods or functions as values. Syntax to define a block uses the caret symbol (^):
^{
    NSLog(@”This is a block”);
}

0 0

Responder chain is a series of responder objects that are linked together. A chain starts with the first responder and ends with the app object. However, when the first responder is unable to handle an event, it forwards it to the next responder in the chain.

0 0
  • Well-tested and mature language
  • Documented frameworks.
  • Strong online support.
  • Works smoothly with C and C++.
  • Stable language.
0 0

It is a pointer to any type, but unlike a void *, it points to an object. For instance, you add anything of type id to an NSArray as long as those objects are responding to retain and release it.

0 0

@interface A:
NSObject;
@end
@interface B : A
@end

Here, the init method is inherited from A to B. However, the method has a different return type in both classes.

0 1

No. Objective-C does not support overloading, so you will need to use a different method.

0 0

It is an object that acts in coordination with, on behalf of, other objects when those objects encounter an event in a program.

If you want to retain a delegate, it can be retained. However, the rule is not to retain it because it must e already retained you will avoid unnecessary retain cycles.

0 0

Because it is a synchronous process. The idea of dispatch_once() is to perform a task only once, no matter how violent the threading becomes.

0 0
NSAutoreleasePool supports Cocoa’s memory management system and it stores objects that are sent when the pool is drained. When you use Automatic Reference Counting, you cannot use autorelease pools. So, you should use @autoreleasepool blocks. For example, instead of:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Code benefitting from a local autorelease pool.
[pool release];
You would write:
@autoreleasepool
{
// Code benefitting from a local autorelease pool.
}
0 0

Add Review

Ask Question