zoukankan      html  css  js  c++  java
  • 广播方式传值

    广播传:

    @IBAction func next(sender: AnyObject){
    let nc=NSNotificationCenter.defaultCenter()
    var a=[String]()
    var b=[String]()
    a.append("phone_num"); a.append("phone_num1");
    b.append(tx_Remark1.text); b.append(tx_Remark2.text);
    let dic=NSDictionary(objects: b, forKeys: a)
    let register2ct = register2CT(nibName: "register2",bundle: nil)
    self.presentViewController(register2ct, animated: false, completion: {
    nc.postNotificationName("phone_num", object: dic)
    })
    }

    广播取:

    import Foundation
    import UIKit

    class register2CT:UIViewController{
    override func viewDidLoad() {
    super.viewDidLoad()
    let nc=NSNotificationCenter.defaultCenter()
    nc.addObserver(self, selector: "handler:", name: "phone_num", object: nil)
    }
    @IBOutlet var quxiao:UIButton!
    var phonenum: String=" "

    @IBAction func OnBackup(sender:AnyObject){
    self.dismissViewControllerAnimated(true, completion:{})
    }

    func handler(ntf:NSNotification){
    let dic = ntf.object as! NSDictionary
    phonenum = dic["phone_num"] as! String
    print(phonenum)
    }

    }

  • 相关阅读:
    bzoj 3944 Sum
    [BZOJ2693]jzptab
    luogu 3768 简单的数学题
    [ZJOI2015]幻想乡战略游戏
    [SDOI2017]数字表格
    [ZJOI2007]Hide 捉迷藏
    [SDOI2016]游戏
    [SPOJ10707]Count on a tree II
    [Luogu4177][CEOI2008]order
    [BZOJ4491]我也不知道题目名字是什么
  • 原文地址:https://www.cnblogs.com/to-creat/p/5375420.html
Copyright © 2011-2022 走看看