Thursday, January 28, 2016

Wednesday, January 27, 2016

Sara Takanashi (高梨沙羅): 女王復活にかける高梨沙羅の本音

Sara Takanashi

Japan vs. Iran (日本×イラン): 2016 AFC U-23 Championship (AFC U-23選手権2016): Quarterfinal (準々決勝): January 22, 2016 (2016年1月22日)

Swift: Adding Sample to Health Store

Swift
@IBAction func addPotassiumTapped(sender : AnyObject){

let potassiumType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryPotassium)

let potassiumQuantity = HKQuantity(unit: HKUnit.gramUnit(), doubleValue: 0.0055)

let potassiumSample = HKQuantitySample(type: potassiumType!, quantity: potassiumQuantity, startDate: NSDate(), endDate: NSDate())

let healthKitStore:HKHealthStore = HKHealthStore()

healthKitStore.saveObject(potassiumSample, withCompletion: { (success, error) -> Void in

if( error != nil ) {

print("Error saving Potassium sample: \(error!.localizedDescription)")

} else {

print("Potassium sample saved successfully!")

}
})
}

Who Ever Said No Two Snowflakes Were Alike?

Tuesday, January 26, 2016

Swift: Request Authorization to Dietary Potassium Data

Swift

@IBOutlet weak var aButton: UIButton!

@IBAction func buttonTapped(sender : AnyObject){

let healthKitStore:HKHealthStore = HKHealthStore()

let healthKitTypesToWrite = Set(
arrayLiteral: HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryPotassium)! )

healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes:nil){ (success, error) -> Void in
if success == false {
}
}

}

Swift: Display an alert

Swift
@IBOutlet weak var aButton: UIButton!

@IBAction func buttonTapped(sender : AnyObject){

let alertController = UIAlertController(title: "My alert", message:

"This is an alert!", preferredStyle: UIAlertControllerStyle.Alert)

alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))

self.presentViewController(alertController, animated: true, completion: nil)
}