The preface
Currently, more and more people are joining the iOS team, even to the point of oversupply. This year, those who have been looking for a job are likely to get a better sense of the tough job market this year, as training agencies rush to send iOS developers to employers, upsetting the ecosystem dynamics. Hypocritical once, get down to business, I offer once, comb for iOS applicant below test questions, hope can help!
I. Written test:
How to understand the MVC design pattern
MVC is an architectural pattern where M stands for MOdel, V for View, and C for Controller:
-
Model stores, defines, and manipulates data;
-
View is used to show the book to the user, and the user operation interaction;
-
The Controller is the coordinator between the Model and the View. The Controller takes the data from the Model and gives it to the View. The Controller can communicate directly with the Model and View, whereas the View cannot communicate directly with the Controller. When there is data update, the MOdel also needs to communicate with the Controller, using Notification and KVO. This way is just like a broadcast. The MOdel sends a signal. The Controller is set to listen to receive signals and send signals to the Controller when there is data update. The Model and View cannot communicate directly, which would violate the MVC design pattern.
How to understand the MVVM design pattern
-
The ViewModel layer, which is the glue between the View and Model layers, is a great place to put user input validation logic, View display logic, network requests, and all sorts of other code. In plain English, the business logic and page logic of the ViewController layer are removed and placed in the ViewModel layer.
-
The View layer, the ViewController layer, its job is to get the data from the ViewModel layer and display it.
Is garbage collection supported in Objective-C?
-
OC supports Garbage collection (GC), but Apple mobile terminals do not support GC, and Mac desktop systems support GC.
-
Mobile terminal development supports ARC (short for Automatic Reference Counting). ARC is a new technology launched after IOS5, which is different from GC mechanism. When we write code, There is no need to send a release or autorelease method to an object, and no need to call the delloc method. The compiler automatically generates an Autorelease message to the user in the appropriate place. ARC features automatic references that simplify memory management.
Understanding and characteristics of OC
-
As an object-oriented language, OC naturally has the characteristics of object-oriented language: encapsulation, inheritance, polymorphism. It has both the features of a static language (such as C++) and the efficiency of a dynamic language (dynamic binding, dynamic loading, and so on). Overall, OC is a great programming language,
-
Objective-c has a number of Dynamic features, which can be seen in three aspects: Dynamic typing, Dynamic binding, and Dynamic loading. Dynamic — something that must not be done until run time.
-
Dynamic typing: The runtime determines the type of an object. This dynamic feature is very common in everyday applications, which is simply the ID type. In fact, static types are more widely used because of their inflexibility and predictability. Static types are strong, while dynamic types are weak, and the runtime determines recipients.
-
Dynamic binding: Based on dynamic typing, once an instance object is identified, its type is determined, and its corresponding properties and response messages are fully determined.
-
Dynamic loading: According to the resources you will need to load demand, the most basic is the adaptation of different models, for example, load on Retina equipment @ 2 x pictures, and on the old some ordinary apple equipment load artwork, let program at runtime to add code modules and other resources, the user can according to need to load some executable code and resources, rather than when it starts loading all of the components, Executable code can contain new classes that are integrated with the program runtime.
The role of categories
-
Add a method to a system class without extending properties. If the name of the method in the class is the same as the name of the method in the system, the method in the class has higher priority when invoked.
-
Implementation of decentralized classes:
+(NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section is a method that originally belongs to NSIndexPath, But because this method is called when the table is used most often and is particularly close to the table, it is declared in uitableView.h as a class of methods.
-
Declare a private method, a method that is only implemented, not declared, is equivalent to a private method.
-
Categories cannot declare variables, and categories cannot add attributes directly. Property describes setter methods, so no errors are reported.
The role of agency
-
Agent, also called delegate, is a design pattern. Agent is the communication interaction between objects. Agent removes the coupling between objects.
-
Change or pass control chains. Allows a class to notify other classes at certain times without having to retrieve Pointers to those classes. You can reduce framework complexity.
-
On another point, proxies can be understood as an analogy to the callback listening mechanism in Java.
-
The proxy attribute is often the reason for assign: it prevents cyclic references so that objects cannot be properly freed.
Ii. Interview
Types that can and cannot be modified in Objective-C
- Modifiable and non-modifiable collection classes are dynamically modifiable and non-dynamically modifiable. For example, NSArray and NSMutableArray, the former after initialization memory control is fixed immutable, the latter can be added, etc., can dynamically apply for new memory space
When we call a static method, do we need to release the object?
- No, static methods (class methods) create an object when the object is already in the automatic release pool. The automatic release pool will most likely be destroyed when it is released.
Why do we need to call the [superDealloc] method when we release our object, and what is its location?
- Because some instances of a subclass inherit from the parent class, the [super Dealloc] method is called to release instances owned by the parent class, which is the subclass itself. Typically we release instances owned by subclasses first, and those owned by the parent class last.
Knowledge of predicates
- Cocoa provides an NSPredicate class that specifies filter conditions. Each object is filtered by a predicate to determine whether the conditions match. If you need to know how to use it, see the specific use of predicates
IsMemberOfClass and isKindOfClass connections and differences
-
Connection: Both detect whether an object is a member of a class
-
Difference: isKindOfClass is used not only to determine whether an object is a member of a class, but also to determine whether an object is derived from a class of that class. IsMemberOfClass can only do the first.
-
For example, if ClassA is derived from NSObject, ClassA *a = [ClassA alloc] init]; ,[a isKindOfClass:[NSObject Class]] can check if a is a member of a derived class from NSObject, but isMemberOfClass cannot.
Description The ID type
- The type of any object is determined at runtime.
** Switch ** statement **if ** statement difference and relation
- The switch statement expression can only handle integer, character, and enumeration types, whereas the flow statement has no such restriction. But switch statements are more efficient than flow control statements.
IsMemberOfClass and isKindOfClass connections and differences
-
Connection: Both detect whether an object is a member of a class
-
Difference: isKindOfClass is used not only to determine whether an object is a member of a class, but also to determine whether an object is derived from a class of that class. IsMemberOfClass can only do the first.
-
For example, if ClassA is derived from NSObject, ClassA *a = [ClassA alloc] init]; ,[a isKindOfClass:[NSObject Class]] can check if a is a member of a derived class from NSObject, but isMemberOfClass cannot.
@public, @protected, and @private
-
@public: the scope of an instance variable of an object can be accessed anywhere;
-
@protected: The object’s instance variable scope is accessible in both its own class and its subclass;
-
@private: The scope of an instance variable can only be accessed within the class itself.
**#import **# include **#import **
-
#include and #import have the same effect, both are actions (methods) defined in the query class;
-
#import does not cause cross-compilation, ensuring that headers are imported only once;
-
@class indicates that only the name of the class is defined, and the behavior of the concrete class is unknown.
* @class compiles more efficiently than #import.
- Furthermore, the main difference between @class and #import is that reference deadlocks are resolved.
The functionality of Core Data
-
Complete and automated support for KVC and KVO integrates appropriate collection access methods to handle multi-valued relationships in addition to integrating KVO and KVC access methods for attributes;
-
Automatic validation of property values;
-
Support for tracking modification and undo operations;
-
Relationship maintenance. Core Data manages the relationship propagation of Data, including maintaining consistency between objects.
-
Group, filter, and organize data in memory and on the interface;
-
Automatic support for object storage in external data warehouses;
-
Create complex requests: Associate NSPredicate in fetch Requests without having to write SQL statements. NSPreadicate supports basic functions, related subqueries, and other advanced SQL features. It supports correct Unicode encoding, region-aware queries, sorting, and regular expressions;
-
Lazy operation: Core Data uses lazyloading to reduce memory load. It also supports partially materialized lazyloading and Data sharing of copied objects.
-
Merge strategy: Core Data has built-in version tracking and optimistic locking to support the resolution of multi-user write conflicts. Optimistic locking detects Data conflicts and returns conflicting information if there are conflicts.
-
Data Migration: Core Data’s Schema Migration tool simplifies the task of dealing with changes in database structure, and in some cases allows you to perform efficient in-place database Migration.
-
Can choose according to program the Controller layer integration, to support the UI display synchronization Core Data on the IPhone OS, providing NSFetchedResultsController object to do related work, On Mac OS X we did this using the Binding mechanism provided by Cocoa.
What are the benefits of using blocks? Use NSTimer to write code that uses blocks to display a stopwatch (on UILabel)
-
Compact code, value, callback are very convenient, save a lot of code to write agent.
-
NSTimer encapsulated into a block, concrete implementation
-
Implementation method: NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 repeats: YES callback: ^ () {weakSelf. SecondsLabel. Text = … } [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
To learn iOS and interested partners can add my QQ469466106 to communicate! ~~ I will also provide you with learning materials, interview materials, I hope that everyone learning iOS can have a bright future, singing all the way, pay as hard as anyone elseCopy the code