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

Refine headers for better API usage experience in Swift #24

Closed sodastsai closed 9 years ago

sodastsai commented 9 years ago

By Apple's recommendation, accessor methods which do return an value but not change internal states should be a property.

For example, the RKRobotBase protocol could be refined to

/*! The basis for any connected device that sends commands and receives responses & broadcasts */
@protocol RKRobotBase <NSObject>

/*! unique identifier - btAddress for Classic and NSUUID for BLE */
@property (nonatomic, readonly) NSString *identifier;
@property (nonatomic, readonly) NSString *serialNumber;
@property (nonatomic, readonly) NSString *name;

-(void) streamCommand:(RKDeviceCommand*) command;
-(void) sendCommand:(RKDeviceCommand *)command;

-(void) addResponseObserver:(id<RKResponseObserver>) observer;
-(void) removeResponseObserver:(id<RKResponseObserver>) observer;

@property (nonatomic, readonly) NSNumber *connectTimeInSeconds;
@property (nonatomic, readonly) RKVersioningResponse *versions;

@property (nonatomic, readonly, getter=isConnected) BOOL connected;

/*! default sleep mode for a robot.  BTLE robots sleep is different from Classic Robots. */
-(void) sleep;

/*! request this robot disconnect */
-(void) disconnect;

@end
zenelk commented 9 years ago

Thanks for your feedback, but due to the way that this works internally the methods that you changed to properties do not make sense in our internal context.