Swift learns _08 from scratch (proxy protocol pass value)

Source: Internet
Author: User

The wording of the proxy agreement in Swift.

This is the first page with a button and a label, button click to jump to the next page.

The second page has an input box and a button, click the button to set the contents of the input box to the content of the first page label. The effect is as follows

Next is the Code section. The same thing as OC. The code for the UI of the first page is no longer written here. Look directly at the code for the second page.

import uikitprotocol secondviewcontrollerdelegate{    // Create agreement }class Secondviewcontroller:uiviewcontroller {    delegate// Set proxy properties         var Testtf:uitextfield!

Creating a protocol and declaring proxy properties

Func DoClick () {//Button Association method implementation        delegate?. Changelabeltext (TextStr:testTF.text)// allow Proxy to execute proxy method    }

The method implementation of the Button association.

Func DoClick () {// Click to jump to next page let        SECONDVC = Secondviewcontroller ()// Create an instance of the second page         SECONDVC.  Delegate = self// set proxy        true)    }    func Changelabeltext (#textStr: String) {// Implement proxy method        println (" Go proxy method ")         = textstr    }

This is the code part of the first page and requires him to accept the agreement.

Conclusion

I started working on the SDK for the past few days. Use of some knowledge is not covered before, such as 8583 package, UnionPay norms, anyway, much, It is still too little to learn to use something new. So the time to learn Swift is limited. There is only a little time to learn. Here are just some simple exercises ...

Swift learns _08 from scratch (proxy protocol pass value)

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: 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.