Inherits from | NSObject |
Declared in | PBWatch+Sports.h |
Overview
Packages a UI update of the sports app.
This container class includes new values of time, distance, pace or speed, heart rate, and a custom label/value. To send the values to the watch use [PBSportsUpdate updateWatch:completion:].
The class is mutable, so consumers can update the values and send the same instance again. Modifying the values of this class will not send the values. The consumer needs to invoke [PBSportsUpdate updateWatch:completion:] every time the UI needs to be updated.
Other Methods
time
The current time in seconds.
@property (nonatomic) NSTimeInterval time
Discussion
The possible range is currently limited from -35999 to 35999, inclusive (±9h 59min 59sec). Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively.
It will be presented as a duration string in the UI. Hours, minutes and seconds will be separated by colons. The hours value will only appear if the value is more than 1 hour. The decimal part will be discarded for the presentation.
Declared In
PBWatch+Sports.h
distance
The current distance in kilometers or miles.
@property (nonatomic) float distance
Discussion
The possible range is currently limited from -99.9 to 99.9, inclusive. Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively.
It will be presented as a decimal number in the UI. The decimal part will be rounded to one digit.
The unit of distance is dependent on the current unit setting.
See Also
Declared In
PBWatch+Sports.h
pace
The current pace in seconds per kilometer or seconds per mile.
@property (nonatomic) NSTimeInterval pace
Discussion
The possible range is currently limited from -3599 to 3599, inclusive (±59min 59sec). Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively.
It will be presented as a duration string in the UI. Minutes and seconds will be separated by colons. The decimal part will be discarded for the presentation.
Currently pace and speed cannot be presented at the same time. Setting speed will discard the value set through pace.
Declared In
PBWatch+Sports.h
speed
The current speed in kilometers per hour or miles per hour.
@property (nonatomic) float speed
Discussion
The possible range is currently limited from -99.9 to 99.9, inclusive. Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively.
It will be presented as a decimal number in the UI. The decimal part will be rounded to one digit.
Currently pace and speed cannot be presented at the same time. Setting pace will discard the value set through speed.
Declared In
PBWatch+Sports.h
heartRate
The current heart rate in beats per minute.
@property (nonatomic) uint8_t heartRate
Discussion
Currently there’s no way to stop sending heart rate values if one heart rate value was sent. The last value will be shown in the UI.
If the heart rate has never been set before, this property will return zero.
Declared In
PBWatch+Sports.h
customLabel
A custom label to show in the sports UI.
@property (nonatomic, copy, nullable) NSString *customLabel
Discussion
The maximum number of characters is ~10, but this maximum is not enforced. The label will be sent in upper case to the watch.
To be sent, both customLabel and customValue have to be set to non-nil values.
Declared In
PBWatch+Sports.h
customValue
A custom value to show in the sports UI.
@property (nonatomic, copy, nullable) NSString *customValue
Discussion
The maximum number of characters is ~8, but the maximum is not enforced.
To be sent, both customValue and customLabel have to be set to non-nil values.
Declared In
PBWatch+Sports.h
appMessageDictionary
Creates an update dictionary from the receiver, that can be used with
[PBWatch sportsAppUpdate:onSent:]
.
@property (nonatomic, readonly) NSDictionary<NSNumber*id> *appMessageDictionary
Discussion
You should prefer using [PBSportsUpdate updateWatch:completion:]
.
See Also
Declared In
PBWatch+Sports.h
– updateWatch:completion:
Sends an update to the watch.
- (void)updateWatch:(PBWatch *)watch completion:(void ( ^ __nullable ) ( NSError *__nullable error ))completion
Parameters
- watch
- The watch to send the update to.
- completion
- Block that will be called when the update either succeeds or fails. error: nil if the operation was successful, or else an NSError with more information on why it failed.
Discussion
The method tries to send the minimal set of changes since the last time the method was used, to try to minimize communication with the watch.
Declared In
PBWatch+Sports.h
+ timeStringFromSeconds:
Creates a formatted time string from a total seconds value, formatted as “h:mm:ss”.
+ (NSString *)timeStringFromSeconds:(NSTimeInterval)seconds
Parameters
- seconds
- The number of seconds from which to create the time string.
Return Value
Formatted time as “h:mm:ss”
Discussion
For example, supplying the value 3930.0f seconds will return @“1:05:30”.
Declared In
PBWatch+Sports.h
+ decimalStringFromFloat:
Creates a formatted decimal string with one decimal number.
+ (NSString *)decimalStringFromFloat:(float)decimal
Parameters
- decimal
- The decimal number to format as a string.
Return Value
The formatted decimal number.
Discussion
For example, supplying the value 13.42f will return @“13.4”.
Declared In
PBWatch+Sports.h
Deprecated Methods
data
General purpose data variable. (Deprecated: Prefer either pace
or speed
.)
@property (nonatomic) float data
Discussion
Note: The original property design is very broken and it has been deprecated in favor of both pace and speed. This value will act as pace from now on.
The possible range is currently limited from -3599 to 3599, inclusive (±59min 59sec). Values larger or smaller than the limits will be transformed into the maximum or minimum, respectively.
It will be presented as a duration string in the UI. Minutes and seconds will be separated by colons. The decimal part will be discarded for the presentation.
Setting a value in either pace or speed will discard the value set through data.
See Also
Declared In
PBWatch+Sports.h
+ updateWithTime:distance:data:
Creates a new PBSportsUpdate
with the given time, distance and data. (Deprecated: Prefer -[PBSportsUpdate init] and filling the properties.)
+ (instancetype)updateWithTime:(NSTimeInterval)time distance:(float)distance data:(float)data
Parameters
- time
- The current time in seconds.
- distance
- The current distance in kilometers or miles.
- data
- General purpose data variable.
Declared In
PBWatch+Sports.h
– dictionary
Creates an update dictionary from the receiver that can be used with
[PBWatch sportsAppUpdate:onSent:]
. (Deprecated: Prefer using -[PBSportsUpdate appMessageDictionary].)
- (NSDictionary *)dictionary
See Also
Declared In
PBWatch+Sports.h
+ timeStringFromFloat:
Creates a formatted time string from a total seconds value, formatted as “h:mm:ss”. (Deprecated: Prefer +[PBSportsUpdate timeStringFromSeconds:].)
+ (NSString *)timeStringFromFloat:(float)seconds
Parameters
- seconds
- The number of seconds from which to create the time string.
Return Value
Formatted time as “h:mm:ss”
Discussion
For example, supplying the value 3930.0f seconds will return @“1:05:30”.
Declared In
PBWatch+Sports.h