MentalDice-Swift
Installation
Pod setup
-
Add
source 'https://github.com/DodyMagic/mentaldice_swift.git'on top of your Podfile -
Add
pod 'MentalDice-Swift'into your Podfile targets -
Run
pod install
Usage
-
Init a list of dice variable from Mental Dice framework:
var dice = MentalDice.shared.dice -
Set yourself as delegate:
MentalDice.shared.delegate = self -
Connect to the Mental Dice:
MentalDice.shared.connect() -
Listen to the delegate protocol:
extension YourClass: MentalDiceDelegate {
func didUpdate(dice: [Die]) {
self.dice = dice
}
func didDetect(color: Die.Color) {
// ...
}
func didConnect() {
// ...
}
func didDisconnect() {
// ...
}
}