IOS value-in-pass mode

Source: Internet
Author: User

1. Initialize the value of the pass (Shun pass)

Custom initialization methods in the UI, usually when one interface pushes another interface, so if you want to use a custom initialization method, at least in this method to create the object, so this method is not suitable for callbacks.

<1> Custom initialization method, which will need to pass the content as parameters, if you need to pass multiple, set multiple parameters

<2> calling custom initialization methods in the right place

2. Attribute value (pass-through)

<1> Defining public properties

<2> need an object that you can pass a value on

<3> attribute Assignment

3. Single-pass values (both shun and inverse)

The advantage of a singleton is that once created, the rest of the time is used at the same time, so a lot of times the user's information is stored in a singleton, so there is no need to make multiple values, only need to create a single case again on the line

4.AppDelegate Transmit Value

<1> a property of life in Appdelegate

<2> by Appdelegate *app = [[Uiapplocation sharedapplication] delegate]; Save property

<3> by Appdelegate *app = [[Uiapplocation sharedapplication] delegate]; Using properties

5. Notification value (pass-through and reverse-pass)

<1> Create a notification sender

<2> Create a notification recipient

<3> Destruction Notification

6. Proxy value (cis-and inverse-pass) (A&B)

B.h: Establishing an agreement to set proxy properties

B.M: Let agents execute protocols and methods when they need agents to do things. (Note: First judgment to prevent crashes)

a.m.: Set up the agent, abide by the protocol, implement the Proxy method

7.block transmit value (pass and reverse) (Declaration and invocation in B are implemented in a)

<1> names The block and writes the parameters that need to be passed in the parameter list as a formal parameter

<2> Set block Properties (note: With week)

<3> set a method to hold the current block

<4> call in the right place

<5> block calls where the object is created

8.NSUserDefault or File value: (Pass and reverse)

[[Nsuserdefault Standarduserdefault] Objectforkey:];

The inverted pass needs to be in Viewwillappear and viewdidappear.

IOS value-in-pass mode

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.