I am new in WatchKit
and stuck in fetching core data object from iOS App. I have one application which fetches the data from iOS App's core data storage. I have added target for my CoreDataManager
file and tried to fetch the data, but every time I receive 0 data. Below is the code which I am using to fetch core data object.
var messages = [Inbox]()
let managedContext = CoreDataManager.sharedInstance.managedObjectContext
let fetchRequest = NSFetchRequest<Inbox>(entityName: "Inbox")
do {
messages = try managedContext.fetch(fetchRequest)
}catch let error as NSError {
print("could not fetch data \(error), \(error.userInfo)")
}
Please let me know what I am doing wrong. As I couldn't find any solution for this or any tutorial for watch OS 3 which fetches the iOS App's core data object to update UI on Watch App. Can we directly access core data object or do we need to use watch Connectivity framework for the same behavior? And if we need to use Watch Connectivity framework then how to share core data object in that. Please help me in this.
Thank you in advance.