Summary of how to transfer values between iOS learning pages

Source: Internet
Author: User

Value three scenarios:

1. Attribute pass-through value (formerly passed back)

Requirements: The Second Interface tab displays the text of the first interface input box.

The first step is to define the properties in the previous interface. (The semantic attribute is declared as copy);

The second step is to pass in the data to the property before entering the next interface.

The third step is to read the data in the latter interface.

2. Proxy transfer value (from back to forward)

Demand:

The first step: Define the protocol in the latter interface, and define a method that has a parameter that has the same parameter type as the value type;

Step Two: Define the proxy properties. The semantic attribute is assign, the type is ID, and the protocol is obeyed .id<xxxdelegate>;

Step three: Look for the proxy object (before push) to specify the proxy object as the previous interface for the latter interface.

Fourth step: Obey the corresponding protocol (directly after the extension of the. m file);

The fifth step: Implement the method in the Protocol;

Sixth step: Tell the Proxy object when (timing) to execute the method in the protocol (Do security processing, respondsto);

Block Pass value (value from forward)

Pending completion.

3. Interval multiple Interface values: The method---single-pass value (similar to the property value).

The first step is to create a singleton class .

Step two : define the method for creating the singleton.

+ (Singleton *) Mainsingleton;

The third step is to define the properties that store the transferred data .

Defining attributes in the. h file
@property (nonatomic, copy) NSString *text;

When implemented in. m files, be aware of the addition of thread protection. (because there may be cases where the singleton has not yet been created, the access is performed.) A single thread ensures that the method created before the access is definitely done, that is, the singleton has been created.)

StaticSingletonnil;//ensures that the singleton is created when the first initialization is made.

+ (Singleton *) Mainsingleton {

@synchronized(self) {

if (! Single) {

single = [[Singleton alloc] init];

}

}

return single ;

}

Summary of how to transfer values between iOS learning pages

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: info-contact@alibabacloud.com 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.