Transfer values between IOS delegate pages

Source: Internet
Author: User

iOS is a lot of page-passing methods, this blog is mainly through the delegation mode to pass value. Pass the value of the time picker in one page to another page

Consists of three main modules

First: Class A

Second: Trust agreement

Third: Class B

First define a delegate uiviewpassvaluedelegate to pass the value

@protocol viewpassvaluedelegate <nsobject>-(void) Passvalue:( NSString *) value; @end

Declare the delegate in Class A, and implement the delegate

@property (nonatomic, unsafe_unretained) id<viewpassvaluedelegate> delegate;

Send Agent

Trajectoryviewcontroller *acceptcontroller = [[Trajectoryviewcontroller alloc] init];//instantiates an object of view 2    Delegte = Acceptcontroller;        Send the agent and pass the values in the text box    [Delegte passvalue:string1];

Class B Declaration Delegate

#import <UIKit/UIKit.h> #import <ViewPassValueDelegate.h> @interface Acceptviewcontroller: Uiviewcontroller<viewpassvaluedelegate> @end

The Protocol method that must be implemented is used to pass values

-(void) Passvalue: (NSString *) value{      NSLog (@ "Passvalue method Get value%@", value);}

Transfer values between IOS delegate 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.