Interview Questions - Basic Knowledge

1. The difference between deep copy and shallow copy

Shallow copy is a pointer copy. Shallow copying an object is equivalent to copying the pointer to the object to generate a new pointer to the object. After the object is destroyed, both pointers should be empty; deep copy is to copy an
object Copying is equivalent to copying the object. The parameter is a new object. When an object is changed or destroyed, the copied new object will not be affected.

2. Lazy loading mode

Lazy loading is also called delayed loading. It is loaded only when needed, and can be used to load controls and properties.
The essence of the lazy loading mode is a special getter method, which contains a piece of code logic for initializing and creating objects inside the getter method, but this logic is only executed once. Advantages
:

  1. Because the lazy loading code logic is only executed once, and it will be executed when it is needed, and it will not be executed when it is not needed, which improves the efficiency of the code and saves the memory resources occupied by the system;
  2. Using the lazy loading mode can put the initialization of the control in the getter method, which can reduce the complexity of the viewDidLoad method, make the code more concise, and reduce the coupling of the code

3. What is the difference between frame and bounds?

The frame refers to: the position and size of the View in the coordinate system of the parent View. (The reference point is the coordinate system of the parent View)
bounds refers to: the position and size of the View in its own coordinate system. (The reference point is the own coordinate system)

4. What is push notification?

Push notification is a technology, there are local push and network push.
A general push notification is a push message from the server to the app.

push implementation

1. The app sends a registration notification to the iOS device, and the user needs to agree to the system sending a push.
2. The iOS app sends the App's Bundle Id and the device's UDID to the APNS remote push server.
3. APNS generates a deviceToken based on the UDID of the device and the Bundle Id of the App and sends it back to the App.
4. The App then sends the deviceToken to the remote push server (its own server), and the server saves it in the database.
5. When your own server wants to send a push, enter the message to be sent in the remote push server and select which user's deviceToken to send to, and the remote push server will send it to APNS.
6. APNS sends it to the corresponding user according to the deviceToken.

5. What is serialization?

  1. The process of converting an object into a sequence of bytes is called serialization of an object
  2. The process of restoring a sequence of bytes to an object is called deserialization of an object

Condition :
It can be used to write objects into files or databases, and can read them out;
follow the NSCoding protocol to realize the storage of complex objects.
After implementing this protocol, it can be packaged or unpacked, and then converted into NSData

Common ways to serialize :

  1. Archive plist file (Foundation own object type, user-defined object type)
  2. CoreData
  3. sqlite
  4. NSUserDefault

6. What is safe release

When the object is released, the pointer points to nil

[p release]
p = nil;

7. Responder chain

**Event Delivery**:

  1. When a touch event occurs in an iOS program, the system will add the event to a task queue managed by UIApplication;
  2. UIApplication distributes the event at the forefront of the task queue, that is, UIWindow
  3. UIWindow distributes events downwards, namely UIView
  4. UIview first checks whether it can handle events and whether the touch point is on itself. If so, continue looking for subviews.
  5. Traverse the child controls and repeat the above two steps.
  6. If not found, then itself is the event handler
  7. If you can't handle it yourself, then don't do any processing.
    Event delivery will first judge whether the responder can respond to the event, and then judge whether it is a suitable View by the following two methods
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

 
responder chain

  • Those who inherit UIResponder can be regarded as a responder is added to the responder chain
  • Starting from the most suitable View found through event delivery, it extends to the superior view to form a chain

The transmission of the event is from top to bottom (parent control to child control), and the response of the event is from bottom to top (upward transmission along the responder chain: child control to parent control)
 

8. Briefly describe the sandbox mechanism

  1. Each application has its own sandbox directory
  2. Can only access its own sandbox directory
  3. Cannot access directories of other applications

Guess you like

Origin blog.csdn.net/guoxulieying/article/details/132021126