// // TestInviteFriendsController.swift // GetHip // // Created by Okechi on 1/23/16. // Copyright (c) 2016 Kroleo. All rights reserved. // import UIKit import MultipeerConnectivity class TestInviteFriendsController: UIViewController, UITableViewDelegate, UITableViewDataSource, PartyServiceManagerDelegate { var usr: [UserParseData] = [] var frnds: [FriendData] = [] var requestData: [FriendData] = [] var isFriendSelected: [Bool] = [] //var isInvitable: [Bool] = [] //var invitableCount = 0 var partyData: PartyServiceManager! = nil @IBOutlet weak var table: UITableView! @IBAction func cancelInvites(sender: UIBarButtonItem) { //println("Browser service deinitialized and browser deinitialized") //self.partyData.stopBrowsing() //self.partyData.serviceBrowser = nil self.parentViewController?.dismissViewControllerAnimated(true, completion: nil) } @IBAction func sendInvites(sender: UIButton) { var numSelected = 0 var data = NSData() for(index, bool) in enumerate(self.isFriendSelected) { if bool == true { //search for foundpeer in array /*for peer in self.partyData.foundPeers { if (peer.displayName == self.frnds[index].displayName){ self.partyData.serviceBrowser.invitePeer(peer, toSession: self.partyData.session, withContext: data, timeout: 3600.0) break } }*/ } } //self.partyData.serviceBrowser.stopBrowsingForPeers() for booli in self.isFriendSelected { if booli == true { numSelected++ } } if(numSelected > 0){ self.performSegueWithIdentifier("selectSongSegue", sender: sender) } else{ println("Select a friend") } } func setData(usrDat: [UserParseData], frndData: [FriendData], party: PartyServiceManager, request: [FriendData]){ self.usr = usrDat self.frnds = frndData self.partyData = party self.requestData = request for i in 0.. Int { // #warning Potentially incomplete method implementation. // Return the number of sections. return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { // #warning Incomplete method implementation. // Return the number of rows in the section. return self.partyData.invitableCount //return self.frnds.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //iterate through the currently found peers and display only friends who are available var friend: FriendData! for i in 0.. Bool { // Return NO if you do not want the specified item to be editable. return true } */ /* // Override to support editing the table view. override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { if editingStyle == .Delete { // Delete the row from the data source tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) } else if editingStyle == .Insert { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } } */ /* // Override to support rearranging the table view. override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { } */ /* // Override to support conditional rearranging of the table view. override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { // Return NO if you do not want the item to be re-orderable. return true } */ /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ } extension TestInviteFriendsController: PartyServiceManagerDelegate { func foundPeer() { //case where friend is nearby and detected after party is started and none were found before if(self.partyData.isInvitable.count == 0){ for i in 0.. Void)!) { } func connectedWithPeer(peerID: MCPeerID) { } func didRecieveInstruction(dictionary: Dictionary){ } }