Created
April 5, 2016 18:14
-
-
Save speaktoalvin/6535afe2920c56d0e096ba0f4bb2b174 to your computer and use it in GitHub Desktop.
Sending Data Using Multipeer from ViewController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class ViewController: UIViewController | |
| { | |
| override func viewDidLoad() | |
| { | |
| super.viewDidLoad() | |
| MultiPeerHelper.sharedInstance.startBrowsingAndAdvertising() | |
| } | |
| func buttonClicked() | |
| { | |
| // Sending Data | |
| let object = MultiPeer_CustomClass(name: "Alvin Varghese", age: 23, email: "[email protected]") | |
| let data : NSData = NSKeyedArchiver.archivedDataWithRootObject(object) | |
| let connectedPeer = MultiPeerHelper.sharedInstance.session.connectedPeers.first // Connected Peer | |
| MultiPeerHelper.sharedInstance.sendDataToDevice(data: data, peedId: connectedPeer!) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment