Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source Swift Library That Simplifies Working With The iOS Multipeer Connectivity API

  •  
  •  
  •  
  •  
  •  

Previously I mentioned a nice source code example on using iOS’s Multipeer Connectivity API along with a getting started tutorial.

Here’s an open source Swift library that simplifies usage of the MultipeerConnectivity framework called PeerKit from JP Simard.

Peerkit greatly simplifies finding and connecting to peers, and sending/receiving data and more.

Here’s some example code from the readme showing how to connect to peers, and send some simple data:

// Automatically detect and attach to other peers with this service type
PeerKit.transceive("com.jpsim.myApp")

enum Event: String {
    case StartGame = "StartGame", EndGame = "EndGame"
}

// Send a StartGame event with attached data to all peers
PeerKit.sendEvent(Event.StartGame.rawValue, object: ["myInfo": "hello!"])

You can find PeerKit on Github here.

You can also find a simple example card game that uses PeerKit on Github here.

A nice framework simplifying the Multipeer Connectivity API.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments