Post

Replies

Boosts

Views

Activity

Reply to CoreData
Found a solution to persist data in Edit Mode. In your Edit View // Core Data Model @ObservedObject var data: Data // Your Text Field @State private var titleInput: String = "" NavigationView { Form { TextEditor(text: $titleInput) } } .onAppear {       self.titleInput = self.data.title }
Aug ’21
Reply to Unable to Save Intents
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) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to How to Fetch SunEvents?
Thank you for the reply @Jineshsethia, I'm only fetching the current date sunEvents and the latitude and longitude details are available in let journalingWeather = CLLocation(latitude: latitude, longitude: longtitude). Could you advise how to use the decoder?
Topic: App & System Services SubTopic: General Tags:
Aug ’22
Reply to On Continue User Activity with Swift UI
Issue resolved with the following code. Might be helpful for future reference for anyone. var coreDataProvider: PersistenceController = .shared @State private var navigationSelection: Panel? = Panel.selectedView @State private var searchedItem: CoreDataEntity = CoreDataEntity() @State private var searchText: String = "" @State private var isShowingDetailView: Bool = false var body: some View { ContentView(searchText: $searchText) .onContinueUserActivity(CSSearchableItemActionType, perform: { activity in // Navigate the search results to the respective view. self.navigationSelection = .selectedView guard let searchString = userActivity.userInfo?[CSSearchQueryString] as? String else { return } // Spotlight search string self.searchText = searchString }) .onContinueUserActivity(CSSearchableItemActionType, perform: { activity in self.navigationSelection = .selectedView if let info = activity.userInfo, let objectIdentifier = info[CSSearchableItemActivityIdentifier] as? String, let objectURI = URL(string: objectIdentifier) { let uri = objectURI let container = coreDataProvider.persistentContainer if let objectID = container.persistentStoreCoordinator.managedObjectID(forURIRepresentation: uri) { if let item = container.viewContext.object(with: objectID) as? CoreDataEntity { // Switch to the state corresponding to the item self.searchedItem = item self.isShowingDetailView = true } } } }) .sheet(isPresented: $isShowingDetailView) { self.isShowingDetailView = false } content: { SpotlightResultsView(searchedItem: $searchedItem, isShowingDetailView: $isShowingDetailView) } } Hope this is helpful and have fun!
Topic: UI Frameworks SubTopic: General Tags:
Aug ’24
Reply to CoreData
Found a guide in WWDC 2021: https://developer.apple.com/videos/play/wwdc2021/10017/
Replies
Boosts
Views
Activity
Jun ’21
Reply to CoreData
Found a solution to persist data in Edit Mode. In your Edit View // Core Data Model @ObservedObject var data: Data // Your Text Field @State private var titleInput: String = "" NavigationView { Form { TextEditor(text: $titleInput) } } .onAppear {       self.titleInput = self.data.title }
Replies
Boosts
Views
Activity
Aug ’21
Reply to Unable to Save Intents
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) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How to Fetch SunEvents?
Thank you for the reply @Jineshsethia, I'm only fetching the current date sunEvents and the latitude and longitude details are available in let journalingWeather = CLLocation(latitude: latitude, longitude: longtitude). Could you advise how to use the decoder?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to How to Fetch SunEvents?
Thank you very much! Ya, it works now!
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Swift UI Preview for Multiple Entity
Found a solution! Can refer to sample code here for solution: https://developer.apple.com/documentation/coredata/adopting_swiftdata_for_a_core_data_app to use multiple entity and to preview your UI in XCode Canvas.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to Xcode 15.3 AppIntentsSSUTraining warning: missing the definition of locale # variables.1.definitions
Thanks @Gong ! Issue resolved after I disabled flexible matching.
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to On Continue User Activity with Swift UI
Issue resolved with the following code. Might be helpful for future reference for anyone. var coreDataProvider: PersistenceController = .shared @State private var navigationSelection: Panel? = Panel.selectedView @State private var searchedItem: CoreDataEntity = CoreDataEntity() @State private var searchText: String = "" @State private var isShowingDetailView: Bool = false var body: some View { ContentView(searchText: $searchText) .onContinueUserActivity(CSSearchableItemActionType, perform: { activity in // Navigate the search results to the respective view. self.navigationSelection = .selectedView guard let searchString = userActivity.userInfo?[CSSearchQueryString] as? String else { return } // Spotlight search string self.searchText = searchString }) .onContinueUserActivity(CSSearchableItemActionType, perform: { activity in self.navigationSelection = .selectedView if let info = activity.userInfo, let objectIdentifier = info[CSSearchableItemActivityIdentifier] as? String, let objectURI = URL(string: objectIdentifier) { let uri = objectURI let container = coreDataProvider.persistentContainer if let objectID = container.persistentStoreCoordinator.managedObjectID(forURIRepresentation: uri) { if let item = container.viewContext.object(with: objectID) as? CoreDataEntity { // Switch to the state corresponding to the item self.searchedItem = item self.isShowingDetailView = true } } } }) .sheet(isPresented: $isShowingDetailView) { self.isShowingDetailView = false } content: { SpotlightResultsView(searchedItem: $searchedItem, isShowingDetailView: $isShowingDetailView) } } Hope this is helpful and have fun!
Topic: UI Frameworks SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’24