public void AddFoodItem(FoodItem item) { var quantityType = HKQuantityType.GetQuantityType(HKQuantityTypeIdentifierKey.DietaryEnergyConsumed); var quantity = HKQuantity.FromQuantity(HKUnit.Joule, item.Joules); var now = NSDate.Now; var metadata = new NSDictionary(HKMetadataKey.FoodType, item.Name); var caloriesSample = HKQuantitySample.FromType(quantityType, quantity, now, now, metadata); HealthStore.SaveObject(caloriesSample, (success, error) => { if (success) { FoodItems.Insert(item, 0); var indexPathForInsertedFoodItem = NSIndexPath.FromRowSection(0, 0); InvokeOnMainThread(() => { TableView.InsertRows(new NSIndexPath[] { indexPathForInsertedFoodItem }, UITableViewRowAnimation.Automatic); }); } else { Console.WriteLine("An error occured saving the food {0}. In your app, try to handle this gracefully. " + "The error was: {1}.", item.Name, error); } }); }