Post

Replies

Boosts

Views

Activity

How to Save User Info to a Post using CloudKit?
1.What is the best way to link/store each User's info to a Post using CloudKit with CoreData? How can I make it that whenever the user changes their photo and I update the UserInfo record, have all the POST made by this user have the new updated photo? .xcdataModel file has a Post entity Post with the following attributes: caption: String, image: binary Data, postID: String, postText: String, userID: String, username: String I use the managedobjectContext method in SwiftUI to add Posts to the database like below.                 post.username = cloudkitManager.currentUser?.name                 post.userID = cloudkitManager.userDefaultsID                 post.postText = self.viewModel.serialNumber                 post.postID = UUID().uuidString                 post.timestamp = Date()                                  if self.viewModel.imageData() != nil {                     post.image  = self.viewModel.imageData()                 }                                  do {                     if viewContext.hasChanges {                         try viewContext.save()                         self.viewModel.isLoading = false                         self.presentationMode.wrappedValue.dismiss()                     }                 } catch {                     self.viewModel.isLoading = false                     let nsError = error as NSError                     self.viewModel.errorMessage = error.localizedDescription                     self.viewModel.showErrorAlert = true                     fatalError("Unresolved error \(nsError), \(nsError.userInfo)")                 } But when saving the UserInfo I use a normal CloudKit container.publicCloudDatabase.save method instead of using the managedObjectContext like above Any Advise please help :)
0
0
495
Jun ’21
Can I use CloudKit to make a Chat Messaging section in app
how can I use CloudKit to make a chat messaging section in my app. I want users to be able to have private conversations with another user without it being public to everyone. I don’t want to use public database cause then everyone would see the 2 users personal convo. I don’t want to use private database because I want both users to be able to see the messages sent to each other in convo. I normally would use Firebase with messagekit for this but I want to try with CloudKit . any help would be appreciated
0
1
825
Oct ’20
How to Add Inline Image Next to Text in SwiftUI
I am trying to add an image to the right of text to make the image appear inline. However when i do this with a HStack the image is to the right of the image for 1 line text but multi line text the image is just to the right of the frame of the view for the text and not Inline as i need eg. HStack { Text("Some Long Text") Image("info.circle") }
1
0
1.4k
Jun ’20