Skip to content

Instantly share code, notes, and snippets.

@jault3
jault3 / PopulateHeight.m
Last active Aug 29, 2015
Populate Height from HealthKit
View PopulateHeight.m
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
// Since we are interested in retrieving the user's latest sample
// we sort the samples in descending order by end date
// and set the limit to 1
NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
// construct the query & since we are not filtering the data the predicate is set to nil
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:heightType predicate:nil limit:1 sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
View Environment.swift
import Foundation
class Environment {
var environmentId: String
var data: Dictionary<String, AnyObject>
var deployed: Bool
var dirty: Bool
init(dict: Dictionary<String, AnyObject>) {
self.environmentId = (dict["environmentId"] as AnyObject?) as String
@jault3
jault3 / messages.json
Last active Aug 29, 2015
Messages Schema
View messages.json
{
"name":"messages",
"schema":{
"msgContent":"string",
"toPhone":"string",
"fromPhone":"string",
"timestamp":"string",
"isPhi":"boolean",
"fileId":"string",
"conversationsId":"string"
@jault3
jault3 / contacts.json
Created Jul 17, 2014
Contacts Schema
View contacts.json
{
"name":"contacts",
"schema":{
"user_username":"string",
"user_usersId":"string"
},
"phi":false
}
@jault3
jault3 / conversations.json
Last active Aug 29, 2015
Conversations Schema
View conversations.json
{
"name":"conversations",
"schema":{
"sender":"string",
"recipient":"string",
"sender_id":"string",
"recipient_id":"string"
},
"phi":true
}
@jault3
jault3 / CurrentUser.m
Created Jun 25, 2014
Get Current User
View CurrentUser.m
[CatalyzeUser currentUser];
View LogIn.m
- (IBAction)login:(id)sender {
[CatalyzeUser logInWithUsernameInBackground:_txtUsername.text password:_txtPassword.text block:^(int status, NSString *response, NSError *error) {
if (error) {
[[[UIAlertView alloc] initWithTitle:@"Error" message:@"Invalid username / password" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
} else {
[self.navigationController pushViewController:[[HealthTrackerViewController alloc] initWithNibName:nil bundle:nil] animated:YES];
}
}];
}
View CatalyzeSignUp.m
- (IBAction)signUp:(id)sender {
Email *email = [[Email alloc] init];
[email setPrimary:_txtEmail.text];
Name *name = [[Name alloc] init];
[name setFirstName:_txtFirstName.text];
[name setLastName:_txtLastName.text];
[CatalyzeUser signUpWithUsernameInBackground:_txtUsername.text email:email name:name password:_txtPassword.text block:^(int status, NSString *response, NSError *error) {
if (error) {
View CatalyzeLogout.m
- (void)logout {
[[CatalyzeUser currentUser] logoutWithBlock:^(int status, NSString *response, NSError *error) {
[self.navigationController popViewControllerAnimated:YES];
}];
}
View QuerySurveys.m
CatalyzeQuery *query = [CatalyzeQuery queryWithClassName:@"surveys"];
[query setPageSize:20];
[query setPageNumber:1];
[query retrieveInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (objects) {
_surveys = [NSMutableArray array];
_otherSurveys = [NSMutableArray array];
for (NSDictionary *dict in objects) {
if ([[dict valueForKey:@"parentId"] isEqualToString:[[CatalyzeUser currentUser] usersId]]) {