Some Questions about iOS and ios

Source: Internet
Author: User

Some Questions about iOS and ios

1. OC Memory Management Mechanism

1 ). when you create an object using the new, alloc, and copy methods, the reserved counter value of this object is 1. when you no longer use this object, you are responsible for sending a release or autorelease message to this object. in this way, the object will be destroyed at the end of its service life.

2 ). when you obtain an object using any other method, assume that the reserved counter value of this object is 1 and has been set to Auto Release, you do not need to perform any operations to ensure that the object is cleared. if you want to own this object for a period of time, you need to keep it and ensure that it is released when the operation is complete.

3). If you retain an object, You Need To (eventually) release or automatically release the object. You must ensure that the retain method and the release method are used equally.

2. What are the advantages of proxy?

The purpose of the proxy is to change or transmit the control chain. Allows a class to notify other classes at certain times without obtaining pointers to those classes. This reduces the complexity of the framework. In addition, the proxy can be understood as a similar callback listening mechanism in java

Advantages: 1. avoid adding too many child classes to subclass and coupling between child classes and parent classes.
2. Hierarchical decoupling through the message delivery mechanism

3. Interface ID

There are two ways to upload the ID on the Interface: a. The upper-level interface (current interface) is sent to the lower-level interface (to be opened). Then, you can directly set the attribute corresponding to the ID on the lower-level interface, before opening the lower-level interface, assign a value to the lower-level interface ID attribute. B. assign a value to the lower-level interface, and then use a proxy (this is not required ), or block (block with the ID parameter ). The method is as follows: the lower-level interface defines a block with the ID parameter. This block is implemented before the upper-level interface opens the lower-level interface. After the lower-level interface triggers the corresponding event, it calls the block

4. Remember the last browsing record

After entering the application, stay on the last page. This is relatively simple. There are several steps: a. After opening an interface, record the current interface (which can be recorded in viewDidLoad); B, in AppDelegate (didFinishLoading .. Find the record in a. If yes, assign the corresponding controller to the rootViewController of window (if push exists, create the controller layer by layer, and then push it one by one until the corresponding interface)

5. Json format

Assume that the person's key is name, and the age key is age: {"name": "Zhang San", "age": "20 "}

JSON is a standard, a bit like NSDictionary, based on the key-value structure

6. Functions of readwrite, readonly, assign, retain, copy, and nonatomic attributes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.