Pass value-Custom constructor pass-through value

Source: Internet
Author: User

The "W" in with must be capitalized when customizing the constructor

For example: Next_viewcontroller requires a value to be passed from Viewcontroller to Next_viewcontroller

such as: in the Viewcontrolle initialization of the same time passed an array into the next_viewcontroller inside. You first need to customize the constructor in the Next_viewcontroller .

-(Instancetype) Initwithlist: (Nsarray *) list{

self = [super init];

if (self) {

NSLog (@ "%@", list);

}

return self;

}

Initialize the Next_viewcontroller object in Viewcontrolle and give Next_viewcontroller an array, so that when you jump into the Viewcontroller, the array is uploaded to the Next_ Viewcontroller Inside for example:

Nsarray *list = @[@ "meat", @ "dish", @ "Rice"];

Next_viewcontroller *next = [[Next_viewcontroller alloc]initwithlist:list];

[Self.navigationcontroller Pushviewcontroller:next Animated:yes];

So you can upload the list to Next_viewcontroller.

Pass value-Custom constructor pass-through value

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.