‘Message to readers šŸ‘‡’

These are my methods to solve problems of iOS interview, and integrate with 100 companies, such as baidu, ali, interview questions, want to answer more detailed look at the title, has links to a more complete answer, come out to share with everyone, the title of answer a little mistake that is normal, hope to be of help. Everyone has a better solution is also welcome to communicate. For technical inadequacy, but also hope understanding and big guy’s guidance!! šŸŽˆ


Finally, welcome to join my iOS communication circle.

+ skirt: 196800191 or + WX (XiAZHiGardenia) Get interview materials resume templates to share technical content including reverse security, algorithms, architecture design, multi-threading, network advancements, as well as underlying, audio and video, Flutter and more…… The point is free!!

The answers below may not be comprehensive, but links to other articles can be directly click on the title!! Check out the answer šŸŽˆ



1.2020 iOS interview question —- Swift and OC difference?

  • (1) The most obvious difference: OC class consists of two files. H and. M, while SWIFT has only one file.
  • (2) Swift is easier to maintain, and the structure is clearer after file separation
  • (3) The main difference between SWIFT and OC is the difference in grammar, and other differences are basically the same.

Difference 1: Swift uses let to define constants and var to define variables. Once a constant is assigned, it cannot be changed, but a variable can be changed after it is assigned. Swift can pull out the exact type of the variable according to the code on the right.


2,2020 iOS Interview Question — Compile links?

  • (1) The difference between ID and in STA NCEType

In sta nceType can only be used as a return value, the compiler determines the true type, does not meet the warning special cases: the associated type return method, such as the class method alloc or new, instance method, autorelease, I nit,reta in, or self


3,2020 — Synthesize & denamic

  • (1) The @$” nthesize “directive tells the compiler to generate getter/setter methods during compilation. (2) The @4” namic directive tells the compiler to generate getter/setter methods.

Some access is created dynamically at run time, such as some used in CoreData’s NSMa nagedObject class. If you want to declare and use properties in these cases, but to avoid missing method warnings at compile time, you can use the @dyn amic dynamic directive instead of the @sy nthesize synthetic directive.


4,2020 iOS Interview questions — What are the most common development tools used in project development?

  • (1) instrument
  • (2) beyondCompare
  • (3) git

Xcode is apple’s integrated Development Environment (IDE) tool that runs on Mac OS X. It can be used to develop Mac OS X and iOS applications. The original version was based on Project Builder, an IDE tool produced by NeXT, a company founded by Jobs.


5,2020 iOS Interview question — UITableView & UICollection

  • (1)UlCollectionView is a new API introduced in iOS6. It is used to display collection view. The layout is more flexible, and its usage is similar to UITableView. While UICollectio nView,

UICollectionViewCell is similar to UITableView and UITableViewCell in usage, but also different. Here are some basic usage methods: Regarding the UITableView, need only UITableViewDataSource, UITableViewDelegate these two protocols, Using UICollectio nView need to implement UICollectio nViewDataSource UICollectionViewDelegate, UICollectionViewDelegateFlowLayout three collaborators, this is because the UICollectio nViewDelegateFlowLayout is actually UICollectio nViewDelegate a child agreement, It inherits the UICollectionViewDelegate, its role is to provide some function definition UICollectionView layout mode


6,2020 iOS Interview questions — NSProxy & NSObject

  • (1)NSObjetct:

The NSObject protocol group applies to all objects under 0bjject -c. If objects comply with this protocol, they are considered first-class objects. In addition, the retain, release, autorelease methods of objects that comply with this agreement are also subject to the object management and release methods defined in Fou NDATIO n. Some objects in containers can also manage these objects, such as those defined by NSArray and NSDictionary. Cocoa’s root classes also follow this protocol, so all objects that inherit from NSObjects have features that follow this protocol. NSProXY: NSProXY is a virtual base class that defines an API for objects that behave like proxies for other objects or that do not exist. Typically, messages sent to the broker are forwarded to a real object or the broker loads (or transforms itself into) a real object. The NSProxy base class can be used to transparently forward messages or to initialize costly objects.


7,2020 iOS Interview question — Object & Swift

  • (1)Obejective -c complex syntax, easier to use and more futuristic, has attracted many developers. Swift has the following obvious features:

Apple claims Swift features are: Fast, modern, safe and interactive, And it’s obviously better than Objective-C and you can use the existing Cocoa and Cocoa Touch frameworks Swift and get rid of Pointers and other insecure access in Objective C and get rid of the Smalltalk syntax in Objective C’s early application, The full change to period notation provides Java-like namespace, gen Eric, and operator overloading. Swift is simply described as “Objective- without C C “(Objective-C without the C) brings Xcode Playgrou NDS to Apple development tools, which provides powerful interactive effects and enables Swift source code to display its results in real time while writing; Based on C and O bjective -c, but without some compatibility constraints of C; Adopt safe programming mode; The interface is based on Cocoa and Cocoa Touch frameworks; Maintains the dynamic nature of Smalltalk


Eight,2020 iOS Interview Question — Deliver Notifications & Push Notifications (Local & Remote)

  • (1) Value-passing notification: similar notification, proxy, Block implementation is worth passing

Push notification: local notification is pushed to the corresponding App of the user’s mobile phone (mainly when it is no longer in the foreground). Local Notificatio n, used for time-based notifications, such as a small application about a calendar or todo list. In addition, if an app is running in the background, iOS allows it to run in a limited amount of time, and it will also find local notifications useful. For example, an application, running in the background, gets a message from the application server, and when the message arrives, such as a message to download an updated version, notifies the user through a local notification mechanism. Local notifications are instances of UILocalNotificatio n and have three main properties: Scheduled Time, which specifies the date and time when OS notifications are sent. Notification Type, the notification type, including the warning message, the title of the action button, the badge (digital badge) on the application icon, and the sound played; Custom data. Local notifications can contain a single dictio nary of local data. The OS allows a maximum of 64 local notifications. If the number exceeds this limit, iOS ignores the local notifications. Remote notification (server required). The process looks like this: 1. Generate CertificateSig nin gRequest. CertSig nin gRequest 2. Upload C ertificateSig nin grequest. certSig nin gRequest to developer and export. Cer file 3. Export P12 file 4 using CSR. Need to prepare the device toKE n value (no space) 5. Use Ope nSSL composite server push certificate used by the general use of aurora push, the steps are the same, but we use the server is aurora, do not need their own large server!


9,2020 iOS Interview Questions — Third-party libraries

00 2020 iOS Interview questions — Third-party platforms
  • (1) Third-party library: generally refers to a framework (library) encapsulated by Daniu, or a library provided by a third party. It is more general here. * Third-party platform: refers to some services provided by a third party.

Libraries: AFN, ASI, Alomofire, MJRefresh, MJExtension, MBProgressHUD Aurora, Baidu, Umeng, Mob, imageName and ImageWithContextOfFile difference? Which performance is high (1) when loading with imageNamed, the image is cached in memory after use, memory consumption is much, and the loading speed is fast. Even if the generated object is released by autoReleasePool, the cache will not be released. If the image is large, or if there are many images, this will consume a lot of memory. ImageNamed uses a caching mechanism, if the cache has loaded images, directly read from the cache, no longer need to read the file, more efficient. (2) ImageWithContextOfFile loading, images are not cached, the loading speed is slow. (3) Extensive use of imageNamed will increase CPU overhead in places where caching is not required. When an application needs to load a large image and use it once, there’s no need to cache the image. Using imageWithCo nTE ntsOfFile is the most economical way to do it, so that it doesn’t have to have a lot of UIImage elements, The CPU is scattered one by one, wasting too much time on unnecessary caches.


10,2020 iOS Interview questions — NSCache & NSDcitionary

  • (1)NSCache differs from mutable sets in several ways:

The NSCache class combines various automatic deletion strategies to ensure that it does not take up too much system memory. If other applications require memory, the system automatically implements these policies. When these policies are invoked, objects are removed from the cache to minimize memory footprint. NSCache is thread-safe, and we can add, remove, and query objects in the cache from different threads without locking the cache area. Unlike NSMutableDictio nary objects, a cache object does not copy a key object. NSCache is similar to NSDictio nary, except that when the system reclaims memory, it automatically erases its contents. ā‘“ can store (of course using memory) ā‘µ keep strong application, ignore garbage collection.= > this has fixed customer with NSMutabledictinary.


11,IOS 2020 interview questions — UIView and setNeedsDisplay and setNeedsLayout methods

methods

  • In Mac OS, the parent class of N SWi ndow is NSRespo nder, while in I OS, the parent class of N SWi ndow is NSRespo nder

UIWi ndow’s superclass is UIVIew. Programs typically have only one window but many views. 2. UIView functions: drawing and animation. The view is responsible for drawing the rectangular area it belongs to, arranging and sub-view management, event processing, receiving touch events, carrier of event information, etc. UIViewController is responsible for creating the views it manages and removing them from memory when memory is low. It also responds to standard system behavior. 4. LayOutSubViews can override this method in its own custom view to adjust the size and position of subviews. UIView setNeedsDisplay (redisplay, draw) and setNeedsLayout (relayout) methods. First, both methods are executed asynchronously. SetNeedsDispla y is going to call this automatic call drawRect method, so you can get uigraphicgetCurre ntCo nText, and you can draw. SetNeedsLayout, by default, calls layoutSubViews to manipulate some data in the subviews. To sum up: setNeedsDisplay is convenient for drawing, while layoutSubViews is convenient for generating data. SetNeedDisplay tells the view that it has changed and needs to redraw itself, which is equivalent to brushing a new interface.


12,2020 iOS Interview question — UIView

>>>>2020 iOS Interview question — UILayer
  • (1)UIView is the basis of interface elements in iOS system, and all interface elements inherit from it. It is fully implemented by CoreAnimation itself (this doesn’t seem to be the case on macs). The real drawing part of it is managed by a class called CALayer (Core Animation Layer).

UIView itself, more like a CALaye manager, accesses its properties related to drawing and coordinates, such as frame, bounds, etc., and actually internally accesses the properties related to CALaye that it contains. UIView has an important property layer that returns its main CALayer instance. UIView’s C ALayer is like a tree of subviews of UIView, and you can add sublayers to its layer to do some particular representation. The CALayer layer can be nested. The layer tree of UIView is maintained inside the system in three copies. These are logical trees, which code can manipulate; The animation tree is an intermediate layer where the system changes ownership and performs various rendering operations. Display tree, the contents of which are currently being displayed on the screen.

Animation operation: Change the subLayer (non-main Layer) property of UIView and animation will be generated automatically. The default duration of animation seems to be 0.5 seconds. Coordinate system :CALaye’s coordinate system has one more anchorPoint property than UIView, represented by CGPoi NT, with a range of 0 to 1, a scale value. ** Render :** When updating layers, changes are not immediately displayed on the screen. When all the layers are ready, the setNeedsDispla y method can be called to redraw the display. ** Transform :** To add a 3D or affine transform to a layer, set the transform or affi neTran sFORM property of the layer, respectively. Morphing: Quartz Core’s rendering capabilities allow 2d images to be manipulated as if they were 3d. Images can be rotated, scaled and tilted at any Angle in a three-dimensional coordinate system. CATra nsform3D’s set of methods provides some magical transformation effects.

The layer tree of UIView is maintained inside the system in three copies.

Logic tree: here is where the code can be manipulated; Animation tree: Is an intermediate layer where the system changes properties and performs various rendering operations; Display tree: The content is what is currently being displayed on the screen.

Animation operation: If you change the subLayer(non-main Layer) property of UIView, the animation will be generated automatically. The default duration of animation seems to be 0.5 seconds.

Coordinate system :CALayer’s coordinate system has one more anchorPoint property than UIView, which is represented by CGPoint structure. The range is 0~1, which is a proportional value.

Render: When updating layers, changes are not immediately displayed on the screen. When all the layers are ready, the setNeedsDisplay method can be called to redraw the display.

Transform: to add a 3D or affineTransform to a layer, set the transform or affineTransform property of the layer, respectively. Morphing :Quartz Core’s rendering capabilities allow 2d images to be freely manipulated as if they were 3d. Images can be rotated, scaled and tilted at any Angle in a three-dimensional coordinate system. A set of CATransform3D methods ō°€ provides some magic transformation effects.


13,2020 iOS Interview question —layoutSubViews & drawRects

  • (1)layoutSubviews are called when the view position change is triggered:

In it initialization does not trigger layoutSubviews. AddSubview triggers layoutSubviews. 3. Setting the Frame of the view triggers layoutSubviews, if the value of the Frame changes before and after setting. 4. Scrolling a UIScrollView triggers l ayoutSubviews. Scree n triggers the layoutSubviews event on the parent UIView. 6. Changing the size of an UlView also triggers layoutSubviews on the parent UlView. 7. Call setLayoutSubviews directly. DrawRect is called when: 1. If the UIView is initialized and the rect size is not set, the drawRect will not be automatically called. DrawRect is dropped after Controller->loadView, Controller-> viewDidLoad ā€¢ So don’t worry about it in Controller, The drawRect of these views will be drawn ā€¢ This allows you to set some values in the controller to the viewIew (if the View draw requires some variable values). So you can calculate size by calling sizeToFit. The system then automatically calls the drawRect: method. 3. Set the con te ntMode attribute to U IViewCo nte ntModeRedraw. DrawRect: is automatically called every time a frame is set or changed. 4. Call setNeedsDisplay directly, or setNeedsDisplayl nRect: to trigger drawRect:, but rect cannot be 0. 1. If UIView is used for drawing, the corresponding contextRef can only be obtained and drawn in drawRect: method. If you get it in any other method, you get an in validate ref and it cannot be used to draw a graph. DrawRect: the method cannot be displayed manually. SetNeedsDisplay or setNeedsDisplayl nRect must be invoked automatically. 2. If you use calayer to draw, you can only draw in drawlnContext: (like fish drawRect) or in the delegate method. Also call setNeedDisplay and other indirect call above method 3, to real-time drawing, can not use gestureRecognizer, can only use touchBega n and other methods to use setNeedsDispla y real-time refresh screen


14,2020 iOS Interview question —UDID & UUID

  • (1)UDID is the abbreviation of Unique Device Ide ntifier, which means Unique Device identifier in Chinese.

This is often used in applications that need to limit one account per device. In the Symbia era, we used IME as the unique identifier of the device. [UIDevice currentDevice] uniqueIdentifier] However, it is important to note that the UDID is not unique to jailbroken devices. Using the Cydia plugin UDIDFaker, you can assign a different UDID to each application. So the use of the UDID as a unique device for identification has become limited. UUID is short for Un iversally Un ique Ide ntifier. According to the web,UUID is a software-built standard, It is also part of the Distributed computing environment (DCE) field organized by Ope N Software Fou Ndatio n (OSF). The purpose of UUID is to enable all elements in a distributed system to have unique identification information, without the need for a central controller to specify identification information.

15,2020 iOS Interview question —CPU & GPU
  • (1)CPU; The central processing unit (Cen TRal Processi NG Un IT) is the computing and control core of a computer. CPU, internal memory and input/output devices are the three core components of electronic computers. Its main function is to interpret computer instructions and process data in computer software.

GPU; English full name Graphic Process ing Unit, Chinese translation “graphics processor”. A dedicated GRAPHICS core processor. The GPU is the “brain” of the graphics card, which determines the grade and most of the performance of the graphics card, and is also the basis for the difference between 2D and 3D graphics cards. 2D display chips mainly rely on CPU processing power when processing 3D images and special effects, which is called “soft acceleration”. The 3D display core concentrates the 3D image and special effects processing functions in the display chip, which is the so-called “hardware speedup” function #### Difference: The reason why CUP and GPU are very different is that they are designed for two different application scenarios. The CPU needs strong commonality to deal with different types of data, and at the same time, logical judgment will introduce a lot of branch jump and interrupt processing. All this makes the internal structure of the CPU extremely complex. On the other hand, GPU is faced with large-scale data with highly unified type and no dependence on each other and pure computing environment without interruption.

There are two approaches to drawing and animation: CPU (central processing unit) and GPU (graphics processing unit). In modern iOS devices, there are programmable chips that can run different software, but for historical reasons we can say that the CPU does all the work at the software level and the GPU does all the work at the hardware level.

In general, we can do everything with software (using the CPU), but for image processing, it’s usually faster with hardware because the GPU is optimized for highly parallel floating-point arithmetic using images. For these reasons, we want to leave screen rendering to the hardware as much as possible. The problem is that the GPU does not have unlimited processing performance, and once the resources run out, performance starts to decline (even if the CPU is not fully occupied).

Most animation performance optimizations are all about using the GPU and CPU intelligently so that they are not overloaded. So we first need to know how Core Animation distributes work between the two processors.

16,2020 iOS Interview Questions — Point (Pt)& pixels (Px)
  • Pixels is the smallest unit of calculation in digital display. With a higher PPI (number of pixels per inch) for the same screen size, you can display more pixels and render more clearly.

Points are a unit of calculation independent of resolution. Depending on the pixel density of the screen, a point can contain multiple pixels (for example, 2 x 2 pixels in 1 pt on a standard Reti NA display). When you design for multiple display devices, you should refer to them in “points,” but design in pixels. This means that you still need to export your ingredients in three different resolutions, regardless of which resolution you design your application at.


17,2020 iOS Interview questions — Attributes and member variables

  • Pixels is the smallest unit of calculation in digital display. With a higher PPI (number of pixels per inch) for the same screen size, you can display more pixels and render more clearly.

Points are a unit of calculation independent of resolution. Depending on the pixel density of the screen, a point can contain multiple pixels (for example, 2 x 2 pixels in 1 pt on a standard Reti NA display). When you design for multiple display devices, you should refer to them in “points,” but design in pixels. This means that you still need to export your ingredients in three different resolutions, regardless of which resolution you design your application at.


18,2020 iOS Interview question —intandNSIntegerThe difference between

  • SIn teger indicates the maximum number of bytes occupied by integer types in the current CPU. The number of bytes occupied by LO ng types varies with DIFFERENT C-PUS. 32-bit in T4 LON G4, 64-bit in T4,lo NG8

(1)import and include import can avoid repeated inclusion. (2)@class can avoid circular references to header files. (3) Global & static variables: Differences between global and static variables. Static variables using static to modify 2 > memory address Both are stored in the static storage area, not on the stack, they separated from the local variable storage 3 > life cycle Both are in the program compiled or assigned by the system automatically when loading, at the end of the program die 4 > external accessibility Global variables in the programs are accessible anywhere, A static variable is equivalent to a private variable in object orientation, and its accessibility is limited to the source file in which it is declared, that is, to this file only


19,2020 iOS Interview Questions — Class and Object

  • (1)1.category

(1) classification to expand what can declare attributes can be in agreement, but only about classification and agreement to create properties method, but not internal to the operation of the member variables (unable to create a member variable), the expansion can be declared (private member variables) agent properties, without actually creating member variable, equivalent to declare the property name corresponding access methods, Classes that comply with the protocol need to implement the corresponding accessor method, otherwise run an error classification declaration attribute, warning prompt need to manually implement accessor method (called computational attribute in Swift), and cannot create member variables in the classification. You can use the run Time objc_setAssociatedObject method in a handwritten accessor method to create properties for an object indirectly (static library adds properties). 1.1 > Add new method is the same as the parent method, but the parent method still needs to use 1.2 > Add New Attribute 2 > Category: 2.1 > For some classes provided by the system, inheritance is not encouraged by the system itself, because the internal implementation of these classes has restrictions on inheritance (NSStri ng ini tWithFormat inheritance crashes). 2.2 > Classes can group methods in the classes they build. For large classes, Improved maintainability (3) The role of classification to spread the implementation of a class across multiple different files or multiple different frameworks. Create a forward reference to a private method. Add an informal protocol to an object. Oc2.o protocal does not have @optio nal, it uses classes to add optional protocols. Oc2.o protocal does not have @optio nal, it uses classes to add optional protocols. Generic constraints such as Kvo’s observeValueForKeyPath belong to the n sobject class and do not need to call the parent class, which means that the implementation of this method is optional. There is no warning that it may be a compiler rule filtering. Name conflict, which means that when a method in a category conflicts with the original class method name, the category takes higher precedence. The class method completely replaces the initial method and can no longer be used. The limitation of not being able to add instance variables can be solved using dictionary objects. 2.extension 3.protocol


20,2020 iOS Interview question —category & extension

  • (1) Categories have three main functions

ā‘“ You can split the implementation of a class into multiple different files or multiple different frameworks for easy code management. You can also provide class extensions to the framework (no source code, no modification). (2) Create a forward reference to a private method: If a method in another class is not implemented, the compiler will report an error when you access a private method in another class. Creating an NSObject class is called “creating a nonformal protocol” because it can be used as a delegate object for any class. The main differences are as follows: 1. Formally, extension is an anonymous categoryO. 2. 3, Extension can add attributes (variables), but not category. Both categories and Exte nsio n are used to add new content to defined classes. There is less coupling between categories and the original class, and declarations and implementations can be written in separate files. The implementation can be written separately, but the implementation must be written in the @impleme ntatio n of the original class. The addition of M ethod and in Sta nee variable o Exte nsio n makes it feel more like the class was designed for encapsulation and other features, and was written at the same time as the class. A category, on the other hand, is a feature that is added temporarily when you use a class in a framework. One of the features of Exte nsio N is that it is possible to redeclare — in sta nee variable, changing it from reado neo to internal readwrite. The use of Exten SIo N can better encapsulate the class. What can be seen in H file are external interfaces. The rest in Sta nee variable and internal @propert y can be written in Exte Nsio N, so that the structure of the class is clearer.


21,2020 iOS Interview question —Foundation

  • (1)(1) the string

1 > String comparison

A = @ nsstrings * “hello”;

NSString *b = [NSString stringWithFormat:@hello “];

If (a ==b){nslog(@ “a==b”); }

if ([a isEqualToString: b]){

Nslog (@ “isEqualToString b”); }

== Compare values stored in variables (addresses) fast content same, possibly different addresses (constant area, heap area)

IsEqualTo Comparing strings is time-consuming

(2) String interception

Interception of string “20 | www.baidu.com”, the character front and the back of the data, output them respectively.

NSString * str = @"20 | [http://www.baidu.com](http://www.baidu.com)"; NSArray *array = [str componentsSeparatedByString:@"|"]; For (int I = 0; i<[array count]; ++i) { NSLog(@"%d=%@",i,[array objectAtIndex:i]);Copy the code

(3) format

<p>NSString *str1 = [NSString stringWithFormat:@<q>a</q>b "]; <br/> NSString *str2 = [NSString stringWithFormat:@ "a"<q>b"]; // display ab<br/> NSString *str3 = [NSString stringWithFormat:@"a\v/q>b"]; </p> </p>Copy the code

22,2020 iOS Interview question —NSArrayandNSDictionary

  • (1) the method of iOS traversing the count dictionary

Array: for loop for in en umerateObjectsUs in gBlock en umerateObjectsWithOptio ns:us in gBlock

1.for(NSString object in [testDic allValues]) 2.for(id akey in [testDic allKeys]){ [sum appendString:[testDic objectForKey:akey]]; } 3.[testDic enumerateKeysAndObjectsUsingBlock:dkey,idobj,BOOLstop) { [sum appendString:obj]; } ]; Speed: Augmenting for is the fastest for arrays. Normal for is about as fast as a block. The fastest enhancement is because the augmenting for syntax buffers the memory addresses of the elements in the container. This is one of the reasons you can’t modify container elements in the body of the loop when using enhanced for (you can add tags in the body and modify elements outside the body). For dictionaries,allValues are the fastest,alKe y is about the same as block, The reason is that allKe y needs to do objcetForKey method (2)NSValue NSNumber 1 > archive view size, coordinates (3) other nil nil NSNull NSNull difference (4) how to avoid cyclic reference two objects strongly reference each other, The solution is to use stro NG for one and assign (weak) for the other.


Need more information on iOS interview collection, plus iOS Technical Exchange group:196800191, group files directly obtain


23,2020 iOS Interview question —CFSocketWhat are the steps to use

  • (1) Answer: create the Socket context; Create a Socket; Configure the server information to be accessed. Sealing server information; Connect to the server;


    24,2020 iOS Interview question —Core FoundationWhich operations are provided inSocketThe method?

  • (1) Answer: CFNetwork, CFSocket and BSD Socket O


    25,2020 iOS Interview Questions — AnalysisXMLWhat kinds of files are available?

  • (1) Answer: Parse XML files in DOM mode; Parsing XML files in SAX;


    26,What is a Sandbox model? Which operations are privateapiCategory?

  • (1) Answer: A certain IPH ONE project has its corresponding designated location for file operation, which cannot be exceeded.

The iPhone sandbox model has four folders: Documents, TMP, APP, Library, and permanent data stores the general Docume NTS folder. The path to the simulator can be obtained using the NSHomeDirectoryO method. The files saved in Nsuserdefaults are in the TMP folder.


27,In an object’s method:selfName =, * * * * * * “object”;andName = “object” ** what’s the difference?

  • Self. name — ‘object ‘: call the setNameO method of the object; Name = “object” : Assigns object directly to the name property of the current object.


    28,2020 iOS Interview Questions — Please explain brieflyviewDidLoad 和 viewDidUnloadWhen to call

  • (1) Answer: viewDidLoad is called when the view is initialized from the NIB file, loadView is called when the view of the controller is nil. Memory warning No tificatio n, viewDidU nload will be called when any view is useless. This is where you implement the view release of the retai N, if it’s the IBOutlet view property of the retain you don’t release it here, IBOutlet will take care of the release.


    29,2020 iOS Interview question — How to create controllers and views

  • (1)


    30,2020 iOS Interview Question — Describe memory partitions

  • (1) Code area: store binary codes of functions

2). Data area: memory is applied and initialized when the system is running, and released by the system when the system exits. Storage of global variables, static variables, constants 3). Heap area: through malloc and other functions or operators such as new dynamic application, programmers need to manually apply and release 4). Stack area: function module application, the end of the function by the system automatically released. Store local variables, function parameters


31,What’s the difference between a queue and a stack

  • (1) ANSWER: Queues and stacks are two different types of data containers. From the point of view of “data structures,” they are linear structures, meaning that the relationships between data elements are the same.

A queue is a first-in, first-out (FIFO) data structure that operates at two ends, with one end for in-queue operation and the other for out-of-queue operation. The stack is a kind of data structure, which can only operate at the top of the stack, and both loading and unloading operate at the top of the stack.


32,2020 iOS Interview question —iOSSystem Architecture

  • (1) a: The iOS system architecture is divided into (theCore OS Layer), (theCore Services Layer) X (theMedia Layer) and (Cocoa Interface service layer the Cocoa Touch) Layer) four layers.


    33,2020 iOS Interview question — Control main response3Kind of event

  • (1) Answer: 1). Touch-based events; 2). Value-based events; 3). Edit-based events.


    34,2020 iOS Interview question —xibThe composition of the document into which3An icon? What functions does it have

  • (1) ANSWER: File’s Owner is each icon in all NIB files. It represents the object that loads the NIB File from disk.

The First Respo nder is the object the user is currently interacting with; View displays the user interface. Complete user interaction; UIView class or a subclass of it.


35,2020 iOS Interview question — Describe the life cycle of a view controller

  • (1)


    36,2020 iOS Interview question —appProject lifecycle

  • (1) Application life cycle

Callbacks to the agent when each program is running: – (BOOL) application: (UIApplication *) application willFinishLaunchingWithOptions: (NSDictionary tell agent into the launchOptions * *) The program is started but has not entered state saving

-(BOOL)application:(UIApplication)application

DidFi nishLau nchi ngWithOptio ns:(NSDictio nary *)la UN chOptio ns tells the agent to start the program basically complete and ready to run

– (void) applicationWillResignActive: (UIApplication *) application when the application is going into the inactive state, in the meantime, the application does not receive messages or events, such as the telephone

– (void) applicationDidBecomeActive: (UIApplication *) application when the application in the active state, this is just the opposite with the above method

– (void) applicationDidEnterBackground: (UIApplication *) application when the program is called when pushed to the background. So to set the background to continue running, you can set it in this function

– (void) applicationWillEnterForeground application: (UIApplication *) when the program is called from the background will be returned to the front desk, this is just the opposite above the method.

– (void) applicationWillTerminate: (UIApplication *) application when the program will exit is invoked, is usually used to store data and some cleanup work before.

(2) A brief description of the startup process of the APP. Speaking of the main file, what functions are there in the main function? What does it do?

The function of the main method during the entire startup process of the app

Open program > Execute main function >UIAPPlicationMain function > Initialization

Set the UIAPPlicationMain function (set the proxy, turn on the event loop) > listen for system events

– > The program is complete

We start with main, and inside main we call UIApplicationMain

(3) UIApplicationMain function

(1) Create a UIApplicati object or a subclass of it based on the third argument passed in. If the argument is nil, it is created using the UIApplication directly. (This parameter can only be passed to UIApplicatio n or a subclass of UIApplicatio n)

(2) Create an AppDelegate object from the fourth argument passed in and assign it to the delegate property of the UIApplicatio n object created in step 1.

Start an event loop that monitors events occurring in the application. The AppDelegate is notified every time a corresponding system event is listened on.

(4) Main function *

ā‘“ Create UIApplicatio n object

(2) Create the application proxy

(3) Start the time loop, including the loop running of the application, and start to process user events.


37,2020 iOS Interview question — What are the basic types of animation? What are the basic styles of table views?

  • (1) Answer: There are two basic types of animation: implicit and explicit.


    38,2020 iOS Interview question — Implementing simple table display requires settingUlTableViewWhat properties and protocols are implemented?

  • (1) ANSWER: To implement a simple table display, you need to set the UITableView dataSource and delegate properties, and implement the UITableViewDataSource and UITableViewDelegate protocol.


    39,2020 iOS Interview question —Cocoa TouchWhat kinds are offeredCore AnimationTransition type?

  • (1) A: Cocoa Touch provides four Core Animation transition types: Cross fade, push, display, and overlay.

CATransition has a variety of transition effects, but in fact, Apple’s official SDK only provides four:

The default moveIn overrides the original image push reveals the bottom but the private API provides a lot of other really cool transition animations, Examples include cube, suckEffect, oglFlip, rippleEffect, pageCurl, and pageUnCurl Scroll down), cameraIrisHollowOpen(camera on), cameraIrisHollowClose(camera off), etc.

Note: Developers are not advised to use these proprietary apis because Apple does not provide maintenance and may cause your app to fail approval.


40,2020 iOS Interview question —UIViewwithCLayerWhat’s the difference?

1).UIView is the basis of interface elements in OS system, and all interface elements are inherited from it. It itself is implemented entirely by CoreA Nimation. The real drawing part of it is managed by a CALayer class. UIView itself is more like a CALayer manager, asking for its properties related to drawing and coordinates. UIView has an important property layer that returns its main CALayer instance. 3).UIView’s CALayer is similar to UIView’s subview tree structure, and it can also add sublayers to its layer to complete some special representations. The CALayer layer can be nested. 4). The layer tree of UIView is maintained in the system with three copies. These are logical trees, which code can manipulate; The animation tree is an intermediate layer on which the system changes properties and performs various rendering operations. Display tree, whose contents are currently being displayed on the screen. 5). Animation operation: If you change the subLayer (non-main Layer) property of UIView, the system will automatically generate animation. The default duration of animation seems to be 0.5 seconds. 6). Coordinate system: CALayer’s coordinate system has one more anchorPoint genus than UIView, which is represented by C GPoi NT structure. The range is 0 ~ 1, which is a proportional value. This point is the origin of the coordinates of the various graph transformations and also changes the positio n position of the layer, which defaults to {0.5,0.5}, i.e. in the center of the layer. 7). Render: When updating layers, changes are not immediately displayed on the screen. When all the layers are ready, the setNeedsDisplay method can be called to redraw the display. 8). Transform: To add a 3D or affine transform to a layer, set the Tran SFORM or Affi neTra NSFORM attributes of the layer respectively. 9). Morphing: Quartz Core’s rendering capabilities allow 2d images to be freely manipulated as if they were 3d. Images can be rotated, scaled and tilted at any Angle in a three-dimensional coordinate system. CATransform3D’s set of methods provides some magical transformation effects.


41,2020 iOS Interview question —Quatrz 2DWhat are the three core concepts of the drawing function

A: Context: mainly used to describe where graphics are written; Path: is the content drawn on the layer; State: Used to save configuration transformation values, padding and Outlines, alpha values, etc.


42,2020 iOS Interview question —iPhone OSHow many ways to play audio are provided?

A. SystemSound Services AVAudioPlayer Audio Queue Services OpenAL


43,2020 iOS Interview Question — UseAVAudioPlayerWhich framework does the class invoke and which steps are used?

A: Avfoundation.framework steps: Configure the AVAudioPlayer object; Implement the AVAudioPlayer class delegate method; Controls objects of the AVAudioPlayer class; Monitor volume levels; Playback progress and drag play.


44,2020 iOS Interview question — What are the methods of gesture notification and clearly write the method name?

A:

-(void)touchesBegan:(NSSet)touchedwithEvent:(UIEvent)event; -(void)touchesMoved:(NSSet)touched withEvent:(UIEvent)event; -(void)touchesEnded:(NSSet)touchedwithEvent:(UIEvent)event; -(void)touchesCanceled:(NSSet)touchedwithEvent:(UIEvent)event; -(void)touchesBegan:(NSSet)touchedwithEvent:(UIEvent)event; -(void)touchesMoved:(NSSet)touched withEvent:(UIEvent)event; - (void) touchesCanceled: NSSet touchedwithEvent: UIEvent) event;Copy the code

45,2020 iOS Interview question —ViewControllerthedidReceiveMemoryWarningHow to get called

Answer :[super didReceiveMemoryWar nin G]; The View Controller will receive this message when the application receives a memory warning: didReceiveMemoryWarning

The ViewController calls didReceiveMemoryWarning when the application receives a memory warning.

2. After calling this method, release the view and call the viewDidUnload method

3. As of iOS3.0, you don’t need to override this function and put the code to free memory in viewDidUnload.


46,2020 iOS Interview Questions — When to Use themdelegate,When to use itN otification?

A: Delegate for the on e-to-O NE relationship is used when the SE nder receives a function feedback from recieve. No tificati on for on e-to-ON E/MA ny/non E,reciver, used to inform multiple object of something. We all know that delegate and Notification are used to pass data between different objects. Here’s a quick look at both:

Delegate is for one-to-one relationships, and reciever can return values to the sender. Nofication is for one-to-one/ AMny/NOe, and Reciever can’t return values to the sender. So, delegate for sender wants to receive feedback from Reciever for a function, and nofication for notifying multiple objects of an event.

When should you use delegate and when should you use Notification?

Using the delegate parameter is more intuitive than using the Notification parameter, so use delegate 2 where possible. Sometimes your page will jump several pages at a time, and it can be a hassle to send data from that page back to the underlying interface because you’re passing the delegate pointer all the way up from the underlying interface. 3. Pass multiple data

When you’re passing to multiple objects from the same object, using a delegate doesn’t work.


47,2020 iOS interview questions — Use preprocessing instruction **#defineDeclare a constant to indicate thatHow many seconds are there in 1** year (ignore the leap year problem)

#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
Copy the code

I want to see in this a couple of things: # define the fundamental knowledge of grammar (for example: can’t end with a semicolon, the use of braces, etc., etc.) to understand the preprocessor will be for you to calculate the value of the constant expression, therefore, direct write you is how to calculate how many seconds – year rather than calculate the actual value, is more clear and without cost. Realize that this expression will overflow an integer on a 16-bit machine – hence the long integer symbol L, which tells the compiler that the constant is a long integer. If you use UL (for unsigned long integers) in your expressions, you have a good starting point. Remember, first impressions count.


48,IOS 2020 — Write a “standard” macroMIN**,** This macro takes two arguments and returns the smaller one.

# define MIN(A,B)	(A)	<= (B) ? (A) : (B))
# define MIN(A,B)	(A)	<= (B) ? (A) : (B))
Copy the code

This test is designed for the purpose of identifying the basics of #defi ne used in macros. This is important because until the embed (in Li NE) operator becomes part of standard C, macros are the only method that facilitates the generation of embedded code, which is often necessary for embedded systems to achieve the desired performance. Knowledge of the triple conditional operator. This operator exists in C because it allows the compiler to produce more optimized code than if-the n-else, and it is important to know how to use it. I also use this question to start talking about the side effects of macros, for example: What happens when you write the code below? least = MIN(p++, b); least = MIN(p++, b); The result is: (p++) <= (b)? (p++) : (p++)) ((p++) <= (b) ? (p++) : (p++)) This expression has the side effect of incrementing the pointer p three times.


49,2020 iOS Interview questions — KeywordsconstWhat does it mean? What about modifiers? staticFor classes? There areExtern C **

  • (1)const means 11 read only”

const int a; int const a; const int *a; int * const a; int const * a const const int a; int const a; const int *a; int * const a; int const * a const; The first two do the same thing. A is a constant integer. The third means that a is a pointer to a constant integer (that is, integers are immutable, but Pointers are). The fourth meaning is that a is a constant pointer to an integer (that is, the integer to which the pointer points is modifiable, but the pointer is not). The last one means that a is a constant pointer to a constant integer (that is, the integer to which the pointer points is immutable, and the pointer is immutable). Conclusion: the purpose of the con st keyword is to convey useful information to the reader of your code. In fact, declaring a parameter as a constant tells the user what the parameter is used for. If you’ve spent a lot of time cleaning up other people’s trash, you’ll quickly learn to appreciate this extra information. (Of course, programmers who know how to use Con ST rarely leave garbage for others to clean up.) Using the keyword con ST may result in tighter code by giving the optimizer some additional information. Proper use of the con st keyword makes it natural for the compiler to protect parameters that are not intended to be changed from inadvertent code modification. In short, it reduces the number of bugs. (1). To prevent a variable from being changed, use the const keyword. When defining this const variable, it is usually necessary to initialize it because there is no opportunity to change it later; (2). For Pointers, we can specify that the pointer itself is con ST, the data to which the pointer points is con ST, or both; (3) in a function declaration, const may modify the parameter to indicate that it is an input parameter and cannot change its value inside the function; (4). A const member function is a const function and cannot modify a member variable of the class. (5). For member functions of a class, it is sometimes necessary to specify that the return value is const so that the return value is not “lvalue”.


50,2020 iOS Interview questions — KeywordsvolatileWhat does it mean? Three different examples are given

  • (1) A: A volatile variable is a variable that can be changed unexpectedly, so that the compiler does not make assumptions about its value. To be precise, the optimizer must carefully re-read the value of the variable each time it is used, rather than using a backup stored in a register.

The following are some examples of volatile variables: Hardware registers on parallel devices (e.g., status registers) Non-automatic variables that are accessed in an interrupt service subroutine and are shared by several tasks in a multithreaded application


51,Can a parameter be volatile as well as const? Can a pointer be volatile?

  • (1) Answer: Yes. One example is a read-only status register. It is volatile because it can be changed unexpectedly. It is con ST because the program should not attempt to modify it.

(2). Yes. Although it’s not very common. An example is when a service subroutine fixes the pointer to a buffe.


52,2020 iOS Interview question —staticThe role of keywords

  • (1) a:

1). Static variable is used by the function body. Unlike auto variable, the memory of this variable is allocated only once, so its value will remain the same in the next call. Static global variables can be accessed by functions inside the module, but not by other functions outside the module. A static function in a module can only be called by other functions in the module. The use of this function is restricted to the module in which it was declared. A static member variable in a class is owned by the entire class. There is only one copy of all objects in the class. 5). The static member function in a class is owned by the entire class. This function does not receive this pointer, so it can only access the static member variable of the class.


53,2020 iOS Interview question — List several process synchronization mechanisms and compare their advantages and disadvantages.

  • (1) Answer: Atom-operated semaphore mechanism spin – locked tube – side, rendezvous, distributed system


    54,2020 iOS Interview question — How processes communicate with each other

  • (1) A: Shared storage system messaging system pipeline: based on the file system


    55,IOS interview question 2020 — The cause of process deadlock

  • (1) Answer: Resource competition and process promotion order are illegal


    56,2020 iOS Interview question — Deadlocked4Essential conditions

  • (1) Answer: Mutually exclusive, request hold, inalienable, loop


    57,IOS interview question 2020 — Deadlock handling

  • (1) Answer: Ostrich strategy, prevention strategy, avoidance strategy, deadlock detection and release


    58,2020 iOS Interview question —cocoa touchThe framework

A: The Cocoa Touch framework, the basis of iPhone OS applications, reuses many of the mature patterns of the Mac system, but it focuses more on the interface and optimization of Touch. UIKit provides you with basic tools to implement graphics and event drivers on iPho NE OS. It is built on the same Fou NDation framework as in Mac OS X, including file handling, network, string manipulation, etc. Cocoa Touch has a special design consistent with the iPho NE user interface. With UIKit, you can use iPho NE OS’s unique graphical interface controls, buttons, and the power of a full-screen view. You can also control your applications using accelerometers and multi-touch gestures. In addition to UIKit, Cocoa Touch includes all the frameworks needed to create world-class iPhone applications, from 3D graphics, to professional sound, and even device access apis to control the camera or know your current location via GPS. Cocoa Touch includes both a powerful Objective-C framework that does everything in just a few lines of code, and a basic C API to access the system directly when needed. These frameworks include: Core An Imation: With Core An Imati on, you can create a rich user experience through a simple programming model based on combining individual layers. Core Audio: Core Audio is a professional technology for playing, processing and recording Audio, making it easy to add powerful Audio capabilities to your applications. Core Data: Provides an object-oriented Data management solution that is easy to use and solve, even with Data models large or small for any application. Here is a small list of the frameworks available in Cocoa Touch: Audio and video: Core Audio, OpenAL, Media Library, AV Foundation :Core Data, SQLite graphics and Animation :Core Animation, OpenGL ES, Quartz 2D: Bonjour, WebKit, BSD Sockets User applications: Address Book, Core Location, Map Kit, Store Kit


59,2020 iOS Interview Questions — What is auto-release Pool and how does it work

  • (1) A: When you send an AutoRelease message to an object, Cocoa puts a reference to that object into the latest autorelease. It is still a valid object, so other objects in the scope defined by the autorelease pool can send messages to it. When the program executes at the end of the scope, the auto-release pool is released, and all objects in the pool are released.


    60,2020 iOS Interview question —sprintf,strcpy,memcpyWhat should be paid attention to in use

  • (1). Spri NTF is a formatting function. To format a piece of data into a string buffer in a specific format. Sprintf formatting functions have an uncontrollable length. It is possible that the formatted string will exceed the size of the buffer, causing an overflow.

Strcpy (char * DST, const char * SRC); strcpy(char * DST, const char * SRC); strcpy(DST, const char * SRC); So this string copy is very error-prone. Memcpy (char DST, const char SRC, unsigned int len); memcpy(DST, const char SRC, unsigned int len); Copy len of memory from SRC to DST. This function has a controllable length. But there is the problem of memory overlay.


61,2020 iOS Interview Questions — You knowsvn,cvsWaiting for version control tools?

  • (1) A: Version control SVN and CVS are two version control devices, which need to support related SVN and CVS services

The port SCM is where version control is configured in Xcode. The principle of version control is that both A and B are working on a project at the same time. A writes the code for the day and submits it to the server. B gets the latest version from the server when he wants to work on it. If a and B both submit to the server and modify the same method at the same time, code conflicts will occur. If A submits the code first, the server will prompt the conflicting code when B submits it, and B can see it clearly and make corresponding modifications or merges the code before submitting it to the server.


62,2020 iOS Interview Questions — What is itpush

  • (1) Answer: The client program leaves a back door port. The client always listens to the request for this back door, so the server can actively push messages to this port.


    63,2020 iOS Interview Question — Static link Library

  • (1) Answer: This is a. A file, equivalent to the Jar package in Java, which compiles some classes into a package. If you import this file, you can use the classes in it in different projects.


    64,2020 iOS Interview question —0CThe three major characteristics

  • (1)(1) Encapsulate point-syntax

1 > nature

“What’s wrong with the following code

–Ā (void)setName:(NSString *)name {

self.name = name;

}

–Ā (NSString *)name {

return self.name;

}

The essence of dot syntax is to call getter and setter methods of a class. You cannot use dot syntax if you do not have getter and setter methods in a class.

(2) inheritance

1 > How to implement multiple inheritance

forward

ForwardingTargetForSelector methodSignatureForSelector forwardInvocation delegate and protocol

category

www.cocoachina.com/ios/2013052…

(3) polymorphism

1 > What is polymorphism

Polymorphism: The ability of different objects to respond to the same message in their own way is called polymorphism.

Since each class belongs to the namespace of that class, this makes polymorphism possible. Names in a class definition do not conflict with names outside the class definition. Instance variables and class methods of a class have the following characteristics: ā€¢ Like data members in C structures, instance variables of a class are in namespaces unique to the class.

ā€¢ Class methods are also in namespaces unique to that class. Unlike method names in C, the method name of a class is not a global symbol. Method names in one class do not conflict with the same method names in other classes. Two completely different classes can implement the same method.

The method name is part of the object interface. The name of the message received by the object is the name of the invoked method. Because different objects can have methods with the same name, objects must be able to understand message semantics. The same message is sent to different objects, resulting in different operations.

The main benefit of polymorphism is that it simplifies the programming interface. It allows for the reuse of some customary names between classes, rather than giving a new name to each newly added function. In this way, a programming interface is a collection of abstract behaviors that are distinguished from the classes that implement the interface.

Objective-c supports polymorphism of method names, but not of parameters and operators.


65,2020 iOS Interview question —0CHow to achieve polymorphism in

  • (1) is done in Objective-C by a selector called selector. In O bjective -c, selector has two meanings, and is used to refer to the method name when used in source messages to objects. It also refers to the unique identifier that replaces the method name when the source code is compiled. The compiled selector type is SEL has the same method with the same name and the same selector. You can use selectors to call methods on an object.

Selectors have the following characteristics: * All methods with the same name have the same selectors * All selectors are different from ā‘“SEL and @selector selectors are of type SEL. The @selector indicator is used to refer to a selector, and the return type is SEL. For example: SEL responseSEL; responseSEL = @selector(loadDataForTableView:); We can get a selector from a string, for example: responseSEL = NSSelectorFromString(@”loadDataForTableView:”); You can also do a reverse conversion to get the methodName, for example, NSString *methodName = NSStringFromSelector(responseSEL); Methods and pickers the picker determines the method name, not the method implementation. This is the foundation of polymorphism and dynamic binding, which makes it possible to send the same message to different classes of objects. Otherwise, there is no difference between sending a message and calling a method in standard C, and it is impossible to support polymorphism and dynamic binding. In addition, class methods of the same name and instance methods of the same class have the same picker. The method return value and parameter type messaging mechanism finds the return value and parameter type of a method through a picker. Therefore, dynamic binding (e.g., sending a message to an object defined by id) requires that the implementation of the method with the same name have the same return value type and the same parameter type. Otherwise, the runtime may fail to find the corresponding method. With one exception, although class methods with the same name and instance methods have the same picker, they can have different parameter types and return value types. <3ā€¢ Dynamic binding


66,2020 iOS Interview question —Objective-CThe advantages and disadvantages of

  • A: ObjC benefits:

(1). Cateogies (2). Posture (3). Dynamic recognition (4). Metric calculation (5). Elastic messaging (6). Not an overly complex C derived language (7). Objective-c and C++ can be mixed programming objC disadvantages: (1). No namespace support (2). Operator overloading is not supported (3). Multiple inheritance is not supported (4). With dynamic runtime types, all methods are function calls, so many compile-time optimization methods are not used. (such as inline functions), poor performance.


67,2020 iOS Interview Questions — Yes0C,What do you think are your greatest strengths and weaknesses? For the deficiencies, is there a way to bypass these deficiencies to fulfill the requirements available now? Have reimplementations been considered or implemented if possible0CIf so, how to do it?

  • (1) The biggest advantage is its runtime features, the deficiency is that there is no namespace, for naming conflicts, can be solved by using long naming method or special prefix, if it is the introduction of third-party library naming conflict, can use link command and flag to resolve the conflict.


    68,2020 iOS Interview question —ocCan be modified and cannot be modified

  • (1) ANSWER: The collection class that can be modified and cannot be modified is the same as that that can be dynamically added and modified. For example, NSArra Y and NSMutableArray, the former after initialization memory control is fixed immutable, the latter can be added, can dynamically apply for new memory space.


    69,2020 iOS Interview Questions — What we saidocWhat do you mean by dynamic runtime language?

  • (1) ANSWER: Polymorphism. Basically, the determination of data types is deferred from compile time to run time. This question actually involves two concepts, run-time and polymorphism.

In simple terms, the runtime mechanism allows us to not determine the class of an object and call the method specified by that class object until runtime. Polymorphism: The ability of different objects to respond to the same message in their own way is called polymorphism. It is assumed that all living things (life) use the same method -eat. Then, human beings and pigs are also creatures. After inheriting life, they both realize their own EAT. However, we only need to call their own EAT methods. That is, different objects respond to the same message in their own way (in response to the eat selector). So you could say that the runtime mechanism is the basis of polymorphism, right? ~ ~ ~


70,2020 iOS Interview Question — What’s the difference between notifications and protocols?

  • (1) Answer: The agreement has the relationship of control chain (HAS-A), but the notice does not.

First of all, I didn’t quite understand what the chain of control was at first. But a brief analysis of the behavior patterns of notifications and brokers gives us a rough idea of what to expect. In simple terms, notifications can be one-to-many, and a message can be sent to multiple message recipients. Acting according to our understanding, not to say directly can not be many, for example we know the star economic agent, a lot of times an economic person is responsible for several star affairs. Just for different stars, the objects of the agency are not the same, one by one correspondence, it is impossible to say that tomorrow to deal with A star to A press conference, the agent issued A news conference processing, do not call B’s press conference. But notifications are different. They only care about sending notifications, not how many are received and interested in processing them. So chain of control (has-a roughly from the English word, a single owned and controllable corresponding relationship.

1. Notification: Notifications need to have a notification center: NSNotificationCenter. To customize notifications, you need to give a name and then listen. Advantages: Neither the sender nor the recipient of a notification needs to know about the other. You can specify a specific method for receiving notifications. The notification name can be any string. Disadvantages: Key-value observation (KVO) requires multiple points of code and must remove listeners before deleting. 2. Protocol setDelegate to set the proxy object, the most typical example is the commonly used TableView. Advantages: The classes that support it have detailed and specific information. Disadvantages: This class must support delegation. Only one delegate can be attached to an object at a time.


71,2020 iOS Interview Question — What is Push Notification?

  • (1) Answer: Push notification is a kind of technology, which is simply a means for the client to obtain resources. In most cases, the client takes the initiative to pull. Push is an active server-side push.


    72,2020 iOS Interview Questions — About polymorphism

A: Polymorphic, a subclass pointer can be assigned to a parent class. This topic can be written in any object-oriented language, so it is generally best to have a self-aware understanding of polymorphism, inheritance, and encapsulation, and it is not necessary to memorize what is written in the book.


73,2020 iOS Interview Questions — What are Predicates?

  • (1) Answer: Predicate is through NSPredicate, is through the given logical conditions as constraints, complete the screening of data.

predicate = [NSPredicate predicateWithFormat:@”customerID == %d”,n]; a = [customers filteredArrayUsingPredicate:predicate]; predicate = [NSPredicate predicateWithFormat:@”customerID == %d”,n]; a = [customers filteredArrayUsingPredicate:predicate];


74,2020 iOS Interview question — Did the project involve network access function, and what objects were used to complete the network function?

  • (1) Answer: ASIHTTPRequest and NSURLConnection


    75,2020 iOS Interview Questions — A brief introductionN SURLConnectionClass and+sendSynchronousRequest:returningResponse:error:And –initWithRequest:delegate: The difference between the two methods?

  • (1) a: NSURLCo nn ectio n is used mainly for network access, where + sendSyn chro nousRequest:retur nin gRespo nse:error: is used to access data synchronously. And wait for the return of the request from respo Nse, while –

In itWithRequest:delegate: uses an asynchronous load. When it’s finished accessing the network, it’s returned to the main thread via the delegate and its delegate object.


76,2020 iOS Interview Question — Talk about itObject-CMemory management mode and process?

+ A: (1). When you create an object using new,alloc, and copy, the object’s retention counter is 1. You are responsible for sending a Release or autoRelease message to the object when you are no longer using it. (2). When you acquire an object by any other method, assume that the object’s retention counter is 1 and that it has been set to auto-free, and that you do not need to do anything to ensure that the object is cleared. If you intend to own the object for a while, you need to keep it and be sure to release it when the operation is done (3). If you keep an object, you need to (eventually) release or automatically release the object. The reTA in and release methods must be used equally.


77,2020 iOS Interview question —Object-CAre there private methods? What about private variables?

  • (1) Answer: There are only two kinds of methods in objective-C classes, static methods and instance methods. This does not seem to be full object orientation, following the OO principle that an object exposes only what is useful. Without private methods, it’s not easy to reuse code on a small scale. Declare a private method in a class

@interface Controller : NSObject { NSString *something; }

  • (void)thisIsAStaticMethod;

One (void)thislsA NLN Sta Nmeyer; @end @interface Controller (private) -(void)thisIsAPrivateMethod; @end@interface Controller: NSObject {NSString *something; }

  • (void) thisIsAStaticMethod;

I. thisIsA nIn sta Nthod; @end @interface Controller (private) -(void)thisIsAPrivateMethod; @end@private can be used to modify private variables so in Objective-C, all instance variables are private by default, all instance methods are public by default


78,2020 iOS Interview Question — Tell me about response chains

  • (1) Answer: Event response chain. Including click events, screen refresh events. Propagate from top to bottom in the view stack, or from bottom to top.

It can be said that the distribution, transmission and processing of events. See the Touch event section for details. Because the question is too abstract, I seriously doubt that the topic will be more general. You can talk about extensibility through event response chain processing in terms of the chain of responsibility model. Description Responder chain When a touch event occurs, the pressure is converted to an electrical signal. The iOS system will generate a UIEve NT object, which records the time and type of the event. Then the system adds the event to an event queue managed by UIApplicati on. UIApplicatio n pulls the first event from the event queue and dispatches the event down for processing. Usually, the main window that sends the event first to the application (keyW in dow) finds the most appropriate view in the view hierarchy to handle touch events (parent to child, back to front). This is the first step in the event handling process, and when the appropriate view control is found, it calls the View control’s Touches method to do the specific thing


79,2020 iOS Interview Question — Time Passing & Responder chain event generation and transmission Process:

  • (1)1. After the touch event occurs, the system adds the event to a queue event managed by UIApplicati

UIApplicati on takes the uppermost event from the event queue and distributes the event for processing, usually first to the main window of the application (keyW in dow) 3. The main window will find the most appropriate view in the view hierarchy to handle touch event 4. When the appropriate view control is found, we call the View control’s Touches method to render the event’s body handling: touchesBegin… touchesMoved… The default approach to these touches is to pass the event up the responder’s chain and call the event to the last one. The touches are passed from the parent control to its child control, and if the parent control doesn’t accept touches, the child control can’t receive them


80,2020 iOS Interview question —frameandboundsWhat’s the difference?

  • (1) Answer: Frame refers to the position and size of the view in the parent view coordinate system. (The reference point is the parent’s coordinate system)

Bounds refers to the position and size of the view in its own coordinate system. (Reference point is its own coordinate system)


81,IOS interview Question 2020 — How are methods and selectors different?

  • A: Selector is the name of a method. Method is a combination of the name and the implementation. See the Apple documentation for details.

82,2020 iOS Interview question —OCGarbage collection mechanism?

  • (1) ANSWER: OC2.0 has Garbage collection, but iOS does not.

O bjective-c is usually manual for memory management, but there are also automatic release pools. But missing most of the information, it seems not to be confused with arc mechanism.


83,IOS interview Question 2020 — What is Lazy loading?

  • (1) Answer: Lazy mode, only when used to initialize, can also be understood as delayed loading. I think one of the best and easiest examples is the loading display of an image in a tableView. A delayed load to avoid high memory, and an asynchronous load to avoid thread clogging.

84,Do you want to embed two views in one view controllertableviewControl the device?

  • (1) ANSWER: A View control only provides a View View, theoretically a tableViewCo ntroller can not put it, can only say that you can embed a TableView View. And, of course, the title itself is a bit of a puzzle if it’s not a UIViewCo ntroller as we think of it qualitatively, but a macro presentation view controller, then we can think of it as a view controller, and it can control multiple view controllers, like TabbarCo Ntroller.

85,2020 iOS Interview Questions — OnetableViewCan two different data sources be associated? How would you handle it?

>>>>UITableView needs to associate different data sources and go back and forth, customize cells, causing data overlap, right? How do you do it?
  • (1) Answer: First of all, we can see from the code how the data source association is actually implemented in the proxy method of data source association.

So we don’t care how we associate it, how it associates, the method is just let me go back and set up the relevant data source as I want. So, I think you can set up multiple data sources, but the question is, what are you trying to do? How do you want the list to be displayed, in different data source partition blocks?


86,2020 iOS Interview Questions — When to Use themNSMutableArrayWhen will it be usedNSArray?

>>>>NSMutableArray thread safety thinking and implementation
  • (1) A: Use NSMutableArray for arrays that need to change while the program is running. Use NSArray for arrays that do not change after initialization. Note that using NSArra y only means that the array does not change at runtime, that is, it cannot add or delete elements to N SAarry’s array, but it does not mean that the contents of the elements in the array cannot be changed. NSArray is thread-safe, NSMutableArray is not thread-safe, multithreaded use of NSMutableArray has to be careful.

87,2020 iOS Interview question — Give an example of the delegation method, and say itUlTableVlewThe Data Source method of

  • (1) a: CocoaTouch framework uses a lot of delegates, UIkbleViewDelegate is a typical application of delegate mechanism, is a typical implementation of the adapter pattern using delegate, UITableViewDelegate protocol is the target, TableView is the adapter, The object that implements the UITableViewDelegate protocol and sets itself as a talbeView delegate is the object that is being treated by the adapter. Normally this object is UITableViewCo ntroller.

-(NSInteger)tableView:(UITableVIew *)tableView numberOfRowsInSection: (NSInteger)section; -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section; -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

Finally, welcome to join my iOS community for information sharing: reverse security, algorithms, architecture, multithreading, network advancements, as well as underlying, audio and video, Flutter and more…… + skirt: 196800191, or + WX (XiAZHiGardenia) Get interview materials and exchange skills together

Word-wrap: break-word! Important; “> < p style =” max-width: 100%; At the same time, if there is a good topic or article, I hope you can share the discussion in the comments section, xiaobian will always pay attention to your comments and timely selection and top oh ~ study together and encourage each other!

At the same time, thank you for your enthusiastic comments ~