sphero-inc / Sphero-iOS-SDK

🚫 DEPRECATED: Sphero™ is the amazing robotic ball ( sphero.com ) created by Orbotix, this is the repository for the iOS SDK for Sphero™. Visit dev site for more information:
http://sdk.sphero.com
225 stars 81 forks source link

Issues with ResponseObservers in Swift 3 #55

Closed gabriellet closed 7 years ago

gabriellet commented 7 years ago

Hi, is there more guidance on how to correctly implement a response observer for Sphero in Swift? I'm having a difficult time doing this correctly and have already looked at the docs to no avail.

iamcgn commented 7 years ago

@gabriellet, If you're using swift 3 the compiler automatically simplified the addResponseObserver and removeResponseObserver methods to just add(observer: RKResponseObserver!) and remove(observer: RKResponseObserver!). As long as you implement the RKResponseObserver protocol you should just need to call robot.add(self).

edit: Also the RKResponseObserver methods have been simplified handleResponse becomes func handle(_ response: RKDeviceResponse!, forRobot robot: RKRobotBase!)

gabriellet commented 7 years ago

Thank you so much! This works!