Sender &という2つのテストアプリがあります。Receiver2つのApps間のデータを迅速にURLスキームで渡しますか?
これらは、URLスキームで互いに通信します。送信者から受信者に文字列を送信したいのですが可能ですか?文字列について
詳細:私の両方がSenderとReceiverにTextFieldを作成
、私は送信者のテキストフィールドにいくつかの文字列をテキストでしょう。ボタンをクリックすると、文字列がReceiver Textfieldに表示されます。ここで
は私のアプリレシーバーコードです:func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
calledBy = sourceApplication
fullUrl = url.absoluteString
scheme = url.scheme
query = url.query
}
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.displayLaunchDetails), name: UIApplicationDidBecomeActiveNotification, object: nil)
// Do any additional setup after loading the view, typically from a nib.
}
func displayLaunchDetails() {
let receiveAppdelegate = UIApplication.sharedApplication().delegate as! AppDelegate
if receiveAppdelegate.calledBy != nil {
self.calledByText.text = receiveAppdelegate.calledBy
}
if receiveAppdelegate.fullUrl != nil {
self.fullUrlText.text = receiveAppdelegate.fullUrl
}
if receiveAppdelegate.scheme != nil {
self.schemeText.text = receiveAppdelegate.scheme
}
if receiveAppdelegate.query != nil {
self.queryText.text = receiveAppdelegate.query
}
}
今のViewControllerでAppdelegateで、私はURLのみlike thisについての情報を表示することができます
いくつかの提案を得ることを望む!
完璧な答え!ので、スキームの後にクエリを追加するクール。 – HungCLo
良い答え。文字列以外のデータを渡す場合は、base64に関する情報を追加する必要があります。 –
偉大な答え、よく説明され、明確な例があります。 – Josh