Objective C Interview Questions and Answers

Last updated on Feb 06, 2023
  • Share
Objective C Interview Questions

Most Frequently Asked Objective C Interview Questions

Here in this article, we will be listing frequently asked Objective C Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q21. What is id?
Answer

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.

Q22. What is an instanceType?
Answer

@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.

Q23. Is there function overloading in Objective-C?
Answer

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

Q24. What is a delegate? Can you retain delegates?
Answer

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.

Q25. How dispatch_once runs only once?
Answer

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.

Q26. What are NSAutoreleasePool and how can we use them?
Answer
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.
}
Reviewed and verified by Best Interview Question
Best Interview Question

With our 10+ experience in PHP, MySQL, React, Python & more our technical consulting firm has received the privilege of working with top projects, 100 and still counting. Our team of 25+ is skilled in...