Hi All, I'm using Core Data to store my data. I've followed the guide in the video but unable to complete the final steps.
/// The core data stack `Data`
var dataProvider: datasProvider = .shared
func handle(intent: CreateNoteIntent, completion: @escaping (CreateNoteIntentResponse) -> Void) {
let title = intent.title!
let isBookmark = intent.isBookmark!
let photo = UIImage()
let newIntent = Task { await self.dataProvider.addData(time: Date(), title: title, isFavorite: isBookmark as! Bool, image: photo) }
let response = CreateNoteIntentResponse(code: .success, userActivity: nil)
response.noteIntent = newIntent //Error: Cannot assign value of type 'Task<(), Never>' to type 'Type'
completion(response)
}
I'm using SwiftUI and it is for iOS app. Does anyone have a solution for this or can explain to me what went wrong please. Spent few hours figuring this out. Any help will be appreciated. Thank you.
Thank you Ricob. Created a new func in CoreDataStack without async to save data from Shortcuts and all data are saved in CoreDataStack successfully.
func handle(intent: CreateNoteIntent, completion: @escaping (CreateNoteIntentResponse) -> Void) {
let title = intent.title!
let isBookmark = intent.isBookmark!
/// Access core data stack `Data` to save the note contents
var dataProvider: datasProvider = .shared
dataProvider.addDataFromShortcut(time: Date(), title: title, isFavorite: isBookmark as! Bool)
let response = CreateNoteIntentResponse(code: .success, userActivity: nil)
completion(response)
}