iOS development-How to pass data from one Viewcontroller to another Viewcontroller (Swift code) by segue writing code

Source: Internet
Author: User

1. Towing Line

Hold down the control key and use the mouse to start with a control on the source controller and drag it to the destination controller

2. Select the pop-up type and set Segue Identifier

In the popup dialog box, select "Selection segue->show"

See

Set Segue Identifier

3. Set the receiving pile in the destination view controller

class Detailviewcontroller:uiviewcontroller {    ...        var deststub:someclass!     ...}

4. Writing data code in the Source view controller

OverrideFunc Prepareforsegue (Segue:uistoryboardsegue, sender:anyobject?)) {        ifSegue.identifier = ="Seguename" {                        ifLet row = Tableview.indexpathforselectedrow?. Row {//here to get your data                Let data = Yourmethod () let Detailviewcontroller= Segue.destinationviewcontroller as!detailviewcontroller detailviewcontroller.deststub = data }} }

iOS development-How to pass data from one Viewcontroller to another Viewcontroller (Swift code) by segue writing code

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.