iOS classic face questions (rpm) (rpm) iOS classic face questions

iOS classic face questions

 

Foreword

The purpose of writing this article is because two days before the students want to apply for iOS development, from the Internet to find iOS interview questions and answers to help me look. I glanced down inhaled air, a closer look, trembling gas. Throughout more than 30 topics no one answer is correct, the author of this summary face questions on iOS mechanism is simply a smattering dare sent to the Internet, whether intentionally or otherwise are hurt newcomers. So here sum up the past few years and some of the interviewing someone I consider a good foundation topic for everyone to share, supplemented by advanced topics in subsequent encounter someone interview. I understand that if there are errors and omissions sure to point out, thank you very much!

From 12 years started the interviewer has now been three years, which face many kinds of development, Tencent, there are Baidu, there are small companies, outsourcing has done, there is no ability to do the code management. I feel that Baidu produced the best technical capabilities, knowledge base, technical details of the master is very solid and confident. Tencent produced the technical details very much, on average, worse than Baidu, but the ability to solve problems is very strong, very active thinking bigger picture is good. Small companies, outsourcing companies classmates technical details, the basics to be worse. I am personally very opposed to the birth of Heroes BAT certainly produced outstanding than other companies, BAT can only say that the technology provided better atmosphere, you can work with more talented people than from small business technical progress easier.

During this period I also face a lot of Internet companies, Tencent, Baidu, Ali, Nora there are many other small and medium sized companies, I feel that the whole Internet interviewer China's attitude is very bad, late habit of regular interviewer , there is reason to meet friends, eat it in the most outrageous is that there is no reason to let you be there. In fact, I think these companies ah not a clear understanding of the status quo, that is, the vast majority of developers are doing just to look at the opportunity, not to the job, so I always find people. While saying how desperate his own company, the candidates came not given due respect. I think the interview is a very bad word, the application process should be called interviews, review more appropriate, it is a process of two-way choice.

I attended no less than fifty times the interview, the interviewer just handed me a glass of water twice, once Tencent technology side, then the interviewer is my most respected leader, and once was Nora hr face. Other interviewers wore sweat Shenzhen direct disregard of the sun came to interview me, basically every time the interview is finished half a dehydrated state. Interview more important is to examine a candidate's ability to work under stress capacity under normal circumstances and not extreme environments, the interviewer should not ask the candidates down, ask some tricky questions to him in a difficult but should be helped candidates ease his tension and stress, and appropriate tips to make candidates maximize, this is a basic quality of qualified interviewer.

iOS interview knowledge

Now get to the Benpian. Benpian face questions that I think good iOS developer to master the basic fundamentals point, I hope you read this post with understanding rather than rote memorization. Rote will soon forget.

1 iOS basis

1.1 parent to achieve a deep copy, how to subclasses to implement deep copy. When the parent does not implement a deep copy, how to subclasses to implement deep copy.

  • Deep copy difference with shallow copy: shallow copy is a copy of the pointer, to a shallow copy of object, pointer to the object equivalent to replicate, produce a new pointer points to the object, then there is a two pointers to the same the object, the object is destroyed after two pointers should be empty. Deep copy is a copy target, copy objects corresponding to produce a new object, then there are two pointers pointing to two objects. When a new object or object changes after being copied out of the affected destroyed.

  • NSCoying achieve deep copy need to implement the protocol, to achieve - (id) copyWithZone: (NSZone *) zone method. When property contains a copy of a property modifier to perform this assignment is actually calling this method.

  • After the parent achieve deep copy, as long as the subclass copyWithZone override method is called the parent class in copyWithZone internal methods, implement the processing after their properties

  • The parent class does not implement a deep copy, sub-classes in addition to their processing properties, but also on the properties of the parent class for processing.

1.2 KVO, NSNotification, delegate and block difference

  • KVO cocoa framework is implemented observer pattern, generally with the use of the same KVC can be monitored by changes in the value of a KVO, such height variations of View. Is one to many relationship, a change in values ​​will notify all observers.
  • NSNotification is to inform, but also to many usage scenarios. In some cases, KVO and NSNotification is the same, after all status changes inform each other. NSNotification characteristic is the need to be proactive notification observer, then the observer listens and then responds registered, and more than a step to send notifications KVO, but its advantage is not limited to changes in the properties of the monitor, but also on a variety of a variety of changes in the state to monitor, monitor a wide range of use is also more flexible.

  • delegate a proxy, that is, I do not want to do things to others to do. Such as dogs need to eat, to notify the owner by delegate, the owner will cook for him, hold rice, pour, these operations, these dogs do not need to care about, just call the delegate (representative) can be, by the other classes needed to complete the operation. So delegate is one to one relationship.

  • Another form of block is delegate, is a form of functional programming. Use the same scene with the delegate, compared to delegate more flexible, and agents to achieve more intuitive.

  • KVO general usage scenario data, demand data changes, such as changes in stock prices, we generally use KVO (observer pattern). delegate general usage scenario is the behavior of the demand is need someone to help me do one thing, such as buying and selling stocks, we generally use the delegate.
    Notification is generally carried out a global notification, such as a good news, telling everyone to buy. delegate is a strong correlation, that is, both the commission and the agent know each other, you let someone else you need to know to buy the stock broker who do not know their customers. Notification is weak association, the good news is issued, you do not need to know who made may also react accordingly, empathy message people do not need to know the person receiving the message can also be issued to normal.

1.3 KVC If implemented, how to find the key. How to implement KVO

Check these two blog posts  KVC  KVO

1.4 a four methods in the main thread execution function

  • GCD methods, by transmitting a block block queue to the main thread, so that the method may be performed in the block in the main thread.
dispatch_async(dispatch_get_main_queue(), ^{      
    //需要执行的方法
});
  • NSOperation method
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];  //主队列
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ //需要执行的方法 }]; [mainQueue addOperation:operation];
  • NSThread method
[self performSelector:@selector(method) onThread:[NSThread mainThread] withObject:nil waitUntilDone:YES modes:nil]; [self performSelectorOnMainThread:@selector(method) withObject:nil waitUntilDone:YES]; [[NSThread mainThread] performSelector:@selector(method) withObject:nil];
  • RunLoop way
[[NSRunLoop mainRunLoop] performSelector:@selector(method) withObject:nil]; 

1.5 How to make timer calls a class method

  • The timer can only call an instance method, but you can call a static method in this instance methods inside.
  • Note that using a timer, the timer must join RunLoop, and choose the right model to run. scheduledTimerWithTimeInterval method creates a timer and added to RunLoop in so you can directly use.
  • If the timer repeats select YES Description This timer will be executed repeatedly, be sure to call invalid timer at the right time. Can not be called in dealloc because once set repeats to yes, the timer will hold strong self, resulting in dealloc never be called, this class will never be released. For example, you can call in viewDidDisappear, so when the class needs to be recovered when you can normally enter in the dealloc.
 [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerMethod) userInfo:nil repeats:YES]; -(void)timerMethod { //调用类方法 [[self class] staticMethod]; } -(void)invalid { [timer invalid]; timer = nil; }

1.6 how to override a class method

  • 1, to achieve a base class with the same name static method in a subclass
  • 2, do not use the class name to call when you call, but using [self class] way call. Principle, with the name of the class is to call early binding, binding at compile time, use [self class] is late binding, decide which method is called at run time.

After 1.7 NSTimer created, in which thread will run.

  • With scheduledTimerWithTimeInterval created, in which thread is created which thread will be added to the RunLoop in which thread will run in
  • Create yourself Timer, added to which thread will run at the RunLoop in which thread.

1.8 id and NSObject * difference

  • id is a objc_object structure pointer, is defined
typedef struct objc_object *id
  • id can be understood as a pointer to an object. All oc object id can point to, the compiler will not do the type checking, id call any of the existing methods are not being given at compile time, of course, if the id is not the object pointed to this method, the collapse or will collapse.

  • NSObject * points must be a subclass of NSObject, calls can only be NSObjec which way do otherwise cast.

  • Subclass objects are not all OC NSObject, and some inherited from NSProxy. Type NSObject * may be directed to a subset of the id.

I understand that if there are errors and omissions sure to point out, thank you very much!

The following supplementary follow-up

iOS core framework

  • CoreAnimation
  • CoreGraphics
  • CoreLocation
  • AVFoundation
  • Foundation

iOS core mechanism

  • Reuse UITableView
  • ObjC memory management; automatic release pond, how to achieve ARC
  • runloop
  • runtime
  • Block definitions, characteristics, memory area, how
  • Responder Chain
  • NSOperation
  • GCD

data structure

  • 8 large sorting algorithm
  • Binary Tree
  • Implement binary search

Object-Oriented Programming

  • Encapsulation, inheritance, polymorphism

  • Design Mode 6 Principles
  • Design a class of functions, how to divide the particle size (single mandate)

  • Interface isolation.

  • If there is a birds have to fly action, it is appropriate to inherit a ostrich do (Richter replacement)

  • How dependent on the degree of coupling between classes dependent on the minimum (Dependency Inversion)
    executives rely on low-rise, low-rise can not rely on high-rise. Dependent interfaces, can not rely on a particular class.

  • A If you want to call C functions, but C is a member of the class B, how to design? (Dmitry)

  • How to design class, can do only add code, without modifying the code, what experience (open closed)
    solved by design patterns.

computer technology

  • Computer Network: TCP / IP, HTTPCDN, SPDY
  • Computer Security: RSA, AES, DES
  • Operating System: threads, processes, stack, deadlocks, scheduling algorithm

iOS new features, new technology

  • iOS7 UIDynamic, SpritKit, new layout, flat
  • iOS8 application extension, HealthKit, SceneKit, CoreLocation, TouchID, PhotoKit
  • iOS9
  • Apple Watch
  • Third-party libraries: SDWebImage, AFNetwork, JSONKit, wax
  • swift

 

Editor: Links

Foreword

The purpose of writing this article is because two days before the students want to apply for iOS development, from the Internet to find iOS interview questions and answers to help me look. I glanced down inhaled air, a closer look, trembling gas. Throughout more than 30 topics no one answer is correct, the author of this summary face questions on iOS mechanism is simply a smattering dare sent to the Internet, whether intentionally or otherwise are hurt newcomers. So here sum up the past few years and some of the interviewing someone I consider a good foundation topic for everyone to share, supplemented by advanced topics in subsequent encounter someone interview. I understand that if there are errors and omissions sure to point out, thank you very much!

From 12 years started the interviewer has now been three years, which face many kinds of development, Tencent, there are Baidu, there are small companies, outsourcing has done, there is no ability to do the code management. I feel that Baidu produced the best technical capabilities, knowledge base, technical details of the master is very solid and confident. Tencent produced the technical details very much, on average, worse than Baidu, but the ability to solve problems is very strong, very active thinking bigger picture is good. Small companies, outsourcing companies classmates technical details, the basics to be worse. I am personally very opposed to the birth of Heroes BAT certainly produced outstanding than other companies, BAT can only say that the technology provided better atmosphere, you can work with more talented people than from small business technical progress easier.

During this period I also face a lot of Internet companies, Tencent, Baidu, Ali, Nora there are many other small and medium sized companies, I feel that the whole Internet interviewer China's attitude is very bad, late habit of regular interviewer , there is reason to meet friends, eat it in the most outrageous is that there is no reason to let you be there. In fact, I think these companies ah not a clear understanding of the status quo, that is, the vast majority of developers are doing just to look at the opportunity, not to the job, so I always find people. While saying how desperate his own company, the candidates came not given due respect. I think the interview is a very bad word, the application process should be called interviews, review more appropriate, it is a process of two-way choice.

I attended no less than fifty times the interview, the interviewer just handed me a glass of water twice, once Tencent technology side, then the interviewer is my most respected leader, and once was Nora hr face. Other interviewers wore sweat Shenzhen direct disregard of the sun came to interview me, basically every time the interview is finished half a dehydrated state. Interview more important is to examine a candidate's ability to work under stress capacity under normal circumstances and not extreme environments, the interviewer should not ask the candidates down, ask some tricky questions to him in a difficult but should be helped candidates ease his tension and stress, and appropriate tips to make candidates maximize, this is a basic quality of qualified interviewer.

iOS interview knowledge

Now get to the Benpian. Benpian face questions that I think good iOS developer to master the basic fundamentals point, I hope you read this post with understanding rather than rote memorization. Rote will soon forget.

1 iOS basis

1.1 parent to achieve a deep copy, how to subclasses to implement deep copy. When the parent does not implement a deep copy, how to subclasses to implement deep copy.

  • Deep copy difference with shallow copy: shallow copy is a copy of the pointer, to a shallow copy of object, pointer to the object equivalent to replicate, produce a new pointer points to the object, then there is a two pointers to the same the object, the object is destroyed after two pointers should be empty. Deep copy is a copy target, copy objects corresponding to produce a new object, then there are two pointers pointing to two objects. When a new object or object changes after being copied out of the affected destroyed.

  • NSCoying achieve deep copy need to implement the protocol, to achieve - (id) copyWithZone: (NSZone *) zone method. When property contains a copy of a property modifier to perform this assignment is actually calling this method.

  • After the parent achieve deep copy, as long as the subclass copyWithZone override method is called the parent class in copyWithZone internal methods, implement the processing after their properties

  • The parent class does not implement a deep copy, sub-classes in addition to their processing properties, but also on the properties of the parent class for processing.

1.2 KVO, NSNotification, delegate and block difference

  • KVO cocoa framework is implemented observer pattern, generally with the use of the same KVC can be monitored by changes in the value of a KVO, such height variations of View. Is one to many relationship, a change in values ​​will notify all observers.
  • NSNotification is to inform, but also to many usage scenarios. In some cases, KVO and NSNotification is the same, after all status changes inform each other. NSNotification characteristic is the need to be proactive notification observer, then the observer listens and then responds registered, and more than a step to send notifications KVO, but its advantage is not limited to changes in the properties of the monitor, but also on a variety of a variety of changes in the state to monitor, monitor a wide range of use is also more flexible.

  • delegate a proxy, that is, I do not want to do things to others to do. Such as dogs need to eat, to notify the owner by delegate, the owner will cook for him, hold rice, pour, these operations, these dogs do not need to care about, just call the delegate (representative) can be, by the other classes needed to complete the operation. So delegate is one to one relationship.

  • Another form of block is delegate, is a form of functional programming. Use the same scene with the delegate, compared to delegate more flexible, and agents to achieve more intuitive.

  • KVO general usage scenario data, demand data changes, such as changes in stock prices, we generally use KVO (observer pattern). delegate general usage scenario is the behavior of the demand is need someone to help me do one thing, such as buying and selling stocks, we generally use the delegate.
    Notification is generally carried out a global notification, such as a good news, telling everyone to buy. delegate is a strong correlation, that is, both the commission and the agent know each other, you let someone else you need to know to buy the stock broker who do not know their customers. Notification is weak association, the good news is issued, you do not need to know who made may also react accordingly, empathy message people do not need to know the person receiving the message can also be issued to normal.

1.3 KVC If implemented, how to find the key. How to implement KVO

Check these two blog posts  KVC  KVO

1.4 a four methods in the main thread execution function

  • GCD methods, by transmitting a block block queue to the main thread, so that the method may be performed in the block in the main thread.
dispatch_async(dispatch_get_main_queue(), ^{      
    //需要执行的方法
});
  • NSOperation method
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];  //主队列
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{ //需要执行的方法 }]; [mainQueue addOperation:operation];
  • NSThread method
[self performSelector:@selector(method) onThread:[NSThread mainThread] withObject:nil waitUntilDone:YES modes:nil]; [self performSelectorOnMainThread:@selector(method) withObject:nil waitUntilDone:YES]; [[NSThread mainThread] performSelector:@selector(method) withObject:nil];
  • RunLoop way
[[NSRunLoop mainRunLoop] performSelector:@selector(method) withObject:nil]; 

1.5 How to make timer calls a class method

  • The timer can only call an instance method, but you can call a static method in this instance methods inside.
  • Note that using a timer, the timer must join RunLoop, and choose the right model to run. scheduledTimerWithTimeInterval method creates a timer and added to RunLoop in so you can directly use.
  • If the timer repeats select YES Description This timer will be executed repeatedly, be sure to call invalid timer at the right time. Can not be called in dealloc because once set repeats to yes, the timer will hold strong self, resulting in dealloc never be called, this class will never be released. For example, you can call in viewDidDisappear, so when the class needs to be recovered when you can normally enter in the dealloc.
 [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerMethod) userInfo:nil repeats:YES]; -(void)timerMethod { //调用类方法 [[self class] staticMethod]; } -(void)invalid { [timer invalid]; timer = nil; }

1.6 how to override a class method

  • 1, to achieve a base class with the same name static method in a subclass
  • 2, do not use the class name to call when you call, but using [self class] way call. Principle, with the name of the class is to call early binding, binding at compile time, use [self class] is late binding, decide which method is called at run time.

After 1.7 NSTimer created, in which thread will run.

  • With scheduledTimerWithTimeInterval created, in which thread is created which thread will be added to the RunLoop in which thread will run in
  • Create yourself Timer, added to which thread will run at the RunLoop in which thread.

1.8 id and NSObject * difference

  • id is a objc_object structure pointer, is defined
typedef struct objc_object *id
  • id can be understood as a pointer to an object. All oc object id can point to, the compiler will not do the type checking, id call any of the existing methods are not being given at compile time, of course, if the id is not the object pointed to this method, the collapse or will collapse.

  • NSObject * points must be a subclass of NSObject, calls can only be NSObjec which way do otherwise cast.

  • Subclass objects are not all OC NSObject, and some inherited from NSProxy. Type NSObject * may be directed to a subset of the id.

I understand that if there are errors and omissions sure to point out, thank you very much!

The following supplementary follow-up

iOS core framework

  • CoreAnimation
  • CoreGraphics
  • CoreLocation
  • AVFoundation
  • Foundation

iOS core mechanism

  • Reuse UITableView
  • ObjC memory management; automatic release pond, how to achieve ARC
  • runloop
  • runtime
  • Block definitions, characteristics, memory area, how
  • Responder Chain
  • NSOperation
  • GCD

data structure

  • 8 large sorting algorithm
  • Binary Tree
  • Implement binary search

Object-Oriented Programming

  • Encapsulation, inheritance, polymorphism

  • Design Mode 6 Principles
  • Design a class of functions, how to divide the particle size (single mandate)

  • Interface isolation.

  • If there is a birds have to fly action, it is appropriate to inherit a ostrich do (Richter replacement)

  • How dependent on the degree of coupling between classes dependent on the minimum (Dependency Inversion)
    executives rely on low-rise, low-rise can not rely on high-rise. Dependent interfaces, can not rely on a particular class.

  • A If you want to call C functions, but C is a member of the class B, how to design? (Dmitry)

  • How to design class, can do only add code, without modifying the code, what experience (open closed)
    solved by design patterns.

computer technology

  • Computer Network: TCP / IP, HTTPCDN, SPDY
  • Computer Security: RSA, AES, DES
  • Operating System: threads, processes, stack, deadlocks, scheduling algorithm

iOS new features, new technology

  • iOS7 UIDynamic, SpritKit, new layout, flat
  • iOS8 application extension, HealthKit, SceneKit, CoreLocation, TouchID, PhotoKit
  • iOS9
  • Apple Watch
  • Third-party libraries: SDWebImage, AFNetwork, JSONKit, wax
  • swift

Guess you like

Origin www.cnblogs.com/wuliaojava/p/11778477.html