Engineering, Design, Marketing, and More

Objective-C interview questions

The most popular questions

Use our complementary questions and answers to filter and hire the best. Questions crowdsourced by our clients, answers by Punch. We provide these complementary questions to help our clients more quickly create tests for potential hires at their organizations.

Get a question answered
Punch offers four divisions of services: design, engineering, staffing, and demand

Interview questions for your next interview

Question
What is difference between NSArray and NSMutableArray in Objective C?
Answer
Mutable means you can change its contents later, Immutable means once they are initialized, their values cannot be changed. So we cannot change NSArray's value after its initialization.
Question
Whats the difference between frame and bounds?
Answer
The frame is the rectangle that defines the UIView with respect to its superview. The bounds of an UIView is the rectangle that is relative to its own coordinate system.

Find developers today

Hire a Punch engineer

Punch offers four divisions of services: design, engineering, staffing, and demand. Our four divisions form the core of our People Forward Approach.

Contact us
Find developers today
Questions
By writing code show how can we achieve singleton pattern in Objective C?
Answer
+ (id)sharedObject {
static id shared;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shared = [[self alloc] init];
});
return shared;
}
Questions
What is atomic and nonatomic? Which one is default?
Answer
You can use this attribute to specify that accessor methods are not atomic. It will ensure the present process is completed by the CPU, before another process accesses the variable. nonatomic specifies that accessors are nonatomic. It is faster and not thread-safe.

By default, accessors are atomic.
Questions
What does the following line says about my Object?id myObject;
Answer
It says that myObject conforms to the Painting protocol.
Questions
How can you declare a method, that can be set as the action to be performed on various events?
Answer
— (IBAction) action:(id) sender;
Questions
Write a function that will take date as NSString and converts it to NSDate object.
Answer
-(NSDate*)stringToDate:(NSString*)dateString{
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSDate *date = [dateFormat dateFromString:dateString];
return date;
}
Questions
Calculate total number of words and character in a given NSString.
Answer
NSString *text = @“Hello World“;

NSArray *words = [text componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSInteger wordCount = [words count];

NSInteger characterCount = 0;
for (NSString *word in words) {
characterCount += [word length];
}
Questions
Sort a NSMutableArray with custom objects in it. (Assume custom array have type Person objects, sort these according to their date of birth)
Answer
NSArray *sortedArray;
sortedArray = [originalArray sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
NSDate *first = [(Person*)a birthDate];
NSDate *second = [(Person*)b birthDate];
return [first compare:second];
}];

Ask a question

Ask a question, and one of our engineers will answer it.

We keep our questions nice and simple to be useful for everyone, and we may not answer or publish every question.

Your number is stored privately and never shared.
By submitting a question, you agree to our terms.
Request sent. Thank you!
Send another one