void UpdateJournal(object sender, EventArgs args) { var calendar = NSCalendar.CurrentCalendar; var startDate = DateTime.Now.Date; var endDate = startDate.AddDays(1); var sampleType = HKSampleType.GetQuantityType(HKQuantityTypeIdentifierKey.DietaryEnergyConsumed); var predicate = HKQuery.GetPredicateForSamples((NSDate)startDate, (NSDate)endDate, HKQueryOptions.None); var query = new HKSampleQuery(sampleType, predicate, 0, new NSSortDescriptor[0], (resultQuery, results, error) => { if (error != null) { Console.WriteLine("An error occured fetching the user's tracked food. " + "In your app, try to handle this gracefully. The error was: {0}.", error.LocalizedDescription); return; } InvokeOnMainThread(() => { FoodItems.RemoveAllObjects(); foreach (HKQuantitySample sample in results) { var foodName = (NSString)sample.Metadata.Dictionary [HKMetadataKey.FoodType]; double joules = sample.Quantity.GetDoubleValue(HKUnit.Joule); var foodItem = FoodItem.Create(foodName, joules); FoodItems.Add(foodItem); } TableView.ReloadData(); }); }); HealthStore.ExecuteQuery(query); }