Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rn-apple-healthkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ym
rn-apple-healthkit
Commits
806ec3ce
Commit
806ec3ce
authored
Jun 29, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added utility functions to Utils
parent
295e4b0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
0 deletions
+109
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
+7
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+102
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
View file @
806ec3ce
...
...
@@ -24,4 +24,11 @@
+
(
NSDate
*
)
endDateFromOptionsDefaultNow
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
;
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
HKUnit
*
)
defaultValue
;
+
(
NSUInteger
)
uintFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSUInteger
)
defaultValue
;
+
(
double
)
doubleFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
double
)
defaultValue
;
+
(
NSDate
*
)
dateFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSDate
*
)
defaultValue
;
+
(
NSString
*
)
stringFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSString
*
)
defaultValue
;
+
(
bool
)
boolFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
bool
)
defaultValue
;
@end
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
806ec3ce
...
...
@@ -60,6 +60,7 @@
+
(
double
)
doubleValueFromOptions
:(
NSDictionary
*
)
options
{
double
value
=
[[
options
objectForKey
:
@"value"
]
doubleValue
];
return
value
;
...
...
@@ -174,6 +175,107 @@
}
+
(
HKUnit
*
)
hkUnitFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
HKUnit
*
)
defaultValue
{
NSString
*
unitString
=
[
options
objectForKey
:
key
];
HKUnit
*
theUnit
;
if
([
unitString
isEqualToString
:
@"gram"
]){
theUnit
=
[
HKUnit
gramUnit
];
}
if
([
unitString
isEqualToString
:
@"pound"
]){
theUnit
=
[
HKUnit
poundUnit
];
}
if
([
unitString
isEqualToString
:
@"meter"
]){
theUnit
=
[
HKUnit
meterUnit
];
}
if
([
unitString
isEqualToString
:
@"inch"
]){
theUnit
=
[
HKUnit
inchUnit
];
}
if
([
unitString
isEqualToString
:
@"foot"
]){
theUnit
=
[
HKUnit
footUnit
];
}
if
([
unitString
isEqualToString
:
@"second"
]){
theUnit
=
[
HKUnit
secondUnit
];
}
if
([
unitString
isEqualToString
:
@"minute"
]){
theUnit
=
[
HKUnit
minuteUnit
];
}
if
([
unitString
isEqualToString
:
@"hour"
]){
theUnit
=
[
HKUnit
hourUnit
];
}
if
([
unitString
isEqualToString
:
@"day"
]){
theUnit
=
[
HKUnit
dayUnit
];
}
if
([
unitString
isEqualToString
:
@"joule"
]){
theUnit
=
[
HKUnit
jouleUnit
];
}
if
([
unitString
isEqualToString
:
@"calorie"
]){
theUnit
=
[
HKUnit
calorieUnit
];
}
if
([
unitString
isEqualToString
:
@"count"
]){
theUnit
=
[
HKUnit
countUnit
];
}
if
([
unitString
isEqualToString
:
@"percent"
]){
theUnit
=
[
HKUnit
percentUnit
];
}
if
(
theUnit
==
nil
){
theUnit
=
defaultValue
;
}
return
theUnit
;
}
+
(
NSUInteger
)
uintFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSUInteger
)
defaultValue
{
NSUInteger
val
;
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
!=
nil
){
val
=
[
num
unsignedIntValue
];
}
else
{
val
=
defaultValue
;
}
return
val
;
}
+
(
double
)
doubleFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
double
)
defaultValue
{
double
val
;
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
!=
nil
){
val
=
[
num
doubleValue
];
}
else
{
val
=
defaultValue
;
}
return
val
;
}
+
(
NSDate
*
)
dateFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSDate
*
)
defaultValue
{
NSString
*
dateString
=
[
options
objectForKey
:
key
];
NSDate
*
date
;
if
(
dateString
!=
nil
){
date
=
[
RCTAppleHealthKit
parseISO8601DateFromString
:
dateString
];
}
else
{
date
=
defaultValue
;
}
return
date
;
}
+
(
NSString
*
)
stringFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
NSString
*
)
defaultValue
{
NSString
*
str
=
[
options
objectForKey
:
key
];
if
(
str
==
nil
){
str
=
defaultValue
;
}
return
str
;
}
+
(
bool
)
boolFromOptions
:(
NSDictionary
*
)
options
key
:(
NSString
*
)
key
withDefault
:(
bool
)
defaultValue
{
NSNumber
*
num
=
[
options
objectForKey
:
key
];
if
(
num
==
nil
){
return
defaultValue
;
}
return
[
num
boolValue
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment