📜 ⬆️ ⬇️

Objective-C questions for middle / senior level

What should the objc developer need to know at the middle / senior level?
Unfortunately, there is no clear line on vertical development. Paradox, but to know what to learn, you need to know what you do not know.
I tried to recall the most interesting questions that I asked myself during various interviews, and also expanded them with a lot of questions (the same level) from myself.
There are no general questions like: IoC, design patterns, SOLID, etc.

ATTENTION!!!
In addition to vertical development, horizontal is also important.

ATTENTION!!! (2)
Do not write in the comments answers to questions, it gives people the opportunity to independently understand.
However, if you have interesting questions on the topic, I’ll be happy to add them to the list.
')
Of course, this is not a substitute for live communication, but it will allow you to prepare well for interviews.


Getting started



what is void *?
what does void mean?

What is the difference between void * and id?

what is id?
How is id defined?
Is it possible to create a structure and result in an id?

id vs instancetype

what does root class mean?
Can I create my own root class?
What are other root classes besides NSObject and NSProxy?

Can I use NSObject instead of NSProxy?
if the answer is yes, then why do you need NSProxy?

How do you align pointers to objects in objc?
what is it connected with?
What optimizations are associated with this when storing data?
why it is impossible to do the implementation?

What is a bridge and why is it needed?

Are all these methods valid? if not, what and why?
- (instancetype)initMyObj { self = nil; return self; } - (instancetype)initmyObj { self = nil; return self; } - (instancetype)myObj { self = nil; return self; } 


What is a meta class?

objc_msgSend, what is this function?
How does this relate to [obj foo]? what else is related functions?

What is a dispatch table?

how is the message being sent?
Are messages always sent at the same speed?

What happens if the method is not found in the dispatch table?

Is there any private methods in objc?
how to test a method not declared in a public interface

exception of sending a message, who throws out?
what is NSInvocation. Give an example of use

what is swizzling?

Is it possible to make private ivar as a property, through a category?
what problems can there be?
how in the category to make your property?

How to make so that on the selector not the method, and the unit has been caused?

What is a selector?

What is a block?
What types of blocks are there?
from which class are inherited?

Does using self inside a block always mean retain cycle?

Why is implicit const used inside the block?

how does __block work?

How does the block call happen?

Assert is used inside the block, what problems arise?
How to eliminate them without highlighting in a separate method?

What is assert and when to use?

What is __autoreleasing?

What is autorelease pool?

What is a run loop?

How are NSTimer and run loop connected?
How to start the timer on a separate thread?
What will happen if you start the timer and keep UIScrollView?
How to fix it?

How are run loop and autorelease pool related?

why in this code memory leak and how to fix?
  NSString *str; while (YES) { str = [NSString stringWithFormat:@"hello world"]; } 

What types of memory management are in objc?

garbage collection vs reference counting?

Differences ARC from MRC?
How does ARC work? How does it determine when to delete an object?
write a setter implementation on MRC

What is the difference between weak and strong and why are there so many runtime functions for this?

why weak cannot be used on some classes?
on which ones?
How to be in this case?

ARC, how does dealloc work?
when are the release messages for ivar?

is the reason for doing true branches? the reason for making a false branch? What does the result depend on?
  BOOL b = 1024; if (b) { NSLog(@"true"); } else { NSLog(@"false"); } 

Do these structures occupy the same memory and why?
 struct StructA { int32_t a; char b; char c; }; struct StructB { char b; int32_t a; char c; }; 

What is union?

and how much memory does this structure occupy and what is it all about?
 struct Value1 { int32_t foo:12; int32_t foo1:4; int32_t foo2:6; int32_t foo3:10; }; struct Value2 { int32_t foo; int32_t foo1; int32_t foo2; int32_t foo3; }; 


What is volatile?

What are inline functions?

What is the difference between flow and process?

NSThread vs pthread

socket, how is this related to the questions above?
tcp, udp when what to apply?

thread race, synchronization methods, critical section protection, semaphore, mutex, barrier, what is it and why?
What is OSSpinLock?

How to transfer data between NSOperation?
when an operation sent to NSOperationQueue starts executing, is it possible to postpone execution?

How to test asynchronous methods?
how to write a synchronous wrapper for an asynchronous method?

What is a call stack and how does it work?
What is the difference between stack and heap?
int8_t matrix [2048] [2024], is it permissible?

recursive functions and tail recursion, can any recursion be tail?

What happens to the reference count when an object is added to the array, dictionary, set?
if you need a different behavior, what to use?
Is it possible to find out which object was added to set? (bag)

How to use your class as a key?

What are the advantages of using immutable?
what are the cons?
Why do we need the copy attribute for property and what problem does it solve?

Why and how does KVC work?
key-path, hacks for collections

Why do you need NSMapTable, what are the differences from NSHashTable

problems when working with KVO and how it all works

frame, bounds, center, how is all this related to each other?
How will the properties change if you apply a 45º turn?
how to move all subviews 3 pt up and left?

Unlike view from layer?

responder working principle
how to send a message to the responder chain?

How do categories work?
at what point is the impact on the classes?
What will happen if the categories intersect?
Why does the category have a name?

Why do you need NSCache? What is the implementation of the cache on NSDictionary?
Does NSURLConnection support HTTP / 2?

What is the typing of objc? Strong / weak, explicit / not explicit, static / dynamic?
What is the difference between QoS User-interactive and user-initiated?
What is the difference between nil / Nil / NULL / NSNull?
________

Once again, do not write the answers to the questions in the comments. The article is not for people to just read the question and answer, but to find the answer on their own and in passing understand.

Article written in conjunction with the complexityclass

Source: https://habr.com/ru/post/273487/


All Articles