Post

Replies

Boosts

Views

Activity

Safely Storing User Logins
I'm developing an app that has accounts with usernames and passwords to log in. So far I have found firebase, which doesn't look bad, but I'd like to know every available option and what they have to offer before committing to one. I was curious if Apple had some sort of kit for developers for a login system. And if not maybe other options for this. Thanks for any help!
0
0
575
Jul ’22
Log In With CloudKit
I'm developing an app that has accounts with usernames and passwords to log in. So far I have found firebase, which doesn't look bad, but I'd like to know every available option and what they have to offer before committing to one. I was curious if Apple had some sort of kit for developers for a login system. Like CloudKit for example, can CloudKit be used to store log in info and be reached when the user is logging in? And if not maybe other options for this. Thanks for any help!
0
0
550
Jul ’22
How to Share an Object Through Airdrop
So I know this is probably a stretch, but is there any way to airdrop an object from core data? From what I understand airdrop is only used with links, but is there a way to convert the data of a core data object into a file, convert the file into a link, send it via airdrop, and convert it back into a file, and then add that object from a file to another user's core data storage? Any help would be greatly appreciated. Thanks!!
0
0
1.3k
Jul ’22
Saving Image in Core Data getting invalid NSEntityDescription Error
I'm currently trying to save a selected image in core data as a type data, but I'm getting an error in the persistence file marked with a comment. I've included my code and any questions I will gladly answer. Thanks for any help! Content View: import SwiftUI import PhotosUI struct ContentView: View {     @ObservedObject var persistence = PersistenceController.shared     @State var selectedItems: [PhotosPickerItem] = []     @State var data: Data?     var body: some View {         NavigationView{             VStack{                 Spacer()                 VStack{                     Spacer()                     if let data = data, let uiimage = UIImage(data: data) {                         Image(uiImage: uiimage)                             .resizable()                             .scaledToFit()                             .frame(width: 250, height: 500)                     }                     Spacer()                 }                 Spacer()                 PhotosPicker(selection: $selectedItems, maxSelectionCount: 1, matching: .images){                     Text("Pick Photo")                 }                 .onChange(of: selectedItems){ newValue in                     guard let item = selectedItems.first else{                         return                     }                     item.loadTransferable(type: Data.self){ result in                         switch result {                         case .success(let data):                             if let data = data{                                 self.data = data                             } else {                                 print("Data is nil")                             }                         case .failure(let failure):                             fatalError("\(failure)")                         }                     }                 }                 Spacer()             }             .navigationBarItems(trailing: addButton)         }     }     var addButton: some View {         Button(action: {             guard let item = selectedItems.first else{                 return             }             item.loadTransferable(type: Data.self){ result in                 switch result {                 case .success(let data):                     if let data = data{                         persistence.addObject(image: data)                     } else {                         print("Data is nil")                     }                 case .failure(let failure):                     fatalError("\(failure)")                 }             }         }){             Text("Add Image").bold()         }     } } Persistence: import Foundation import CoreData class PersistenceController: ObservableObject {     static let shared = PersistenceController()     let container: NSPersistentContainer     init(inMemory: Bool = false) {         container = NSPersistentContainer(name: "ReciPlanner")         if inMemory {             container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")         }         container.loadPersistentStores(completionHandler: { (storeDescription, error) in             if let error = error as NSError? {                 fatalError("Unresolved error \(error), \(error.userInfo)")             }         })         container.viewContext.automaticallyMergesChangesFromParent = true     }          func addObject(image: Data){         let context = container.viewContext         let object = Object(context: context) //Error: Thread 7: "An NSManagedObject of class 'Object' must have a valid NSEntityDescription."         object.item = image     }          func contextSave() {         let context = container.viewContext         if context.hasChanges {             do {                 try context.save()             } catch {                 print("**** ERROR: Unable to save context \(error)")             }         }     } } Data Model:
0
0
931
Jul ’22
Saving Image in Core Data getting invalid NSEntityDescription Error
I'm currently trying to save a selected image in core data as a type data, but I'm getting an error in the persistence file marked with a comment. I've included my code and any questions I will gladly answer. Thanks for any help! Content View: import SwiftUI import PhotosUI struct ContentView: View {     @ObservedObject var persistence = PersistenceController.shared     @State var selectedItems: [PhotosPickerItem] = []     @State var data: Data?     var body: some View {         NavigationView{             VStack{                 Spacer()                 VStack{                     Spacer()                     if let data = data, let uiimage = UIImage(data: data) {                         Image(uiImage: uiimage)                             .resizable()                             .scaledToFit()                             .frame(width: 250, height: 500)                     }                     Spacer()                 }                 Spacer()                 PhotosPicker(selection: $selectedItems, maxSelectionCount: 1, matching: .images){                     Text("Pick Photo")                 }                 .onChange(of: selectedItems){ newValue in                     guard let item = selectedItems.first else{                         return                     }                     item.loadTransferable(type: Data.self){ result in                         switch result {                         case .success(let data):                             if let data = data{                                 self.data = data                             } else {                                 print("Data is nil")                             }                         case .failure(let failure):                             fatalError("\(failure)")                         }                     }                 }                 Spacer()             }             .navigationBarItems(trailing: addButton)         }     }     var addButton: some View {         Button(action: {             guard let item = selectedItems.first else{                 return             }             item.loadTransferable(type: Data.self){ result in                 switch result {                 case .success(let data):                     if let data = data{                         persistence.addObject(image: data)                     } else {                         print("Data is nil")                     }                 case .failure(let failure):                     fatalError("\(failure)")                 }             }         }){             Text("Add Image").bold()         }     } } Persistence: import Foundation import CoreData class PersistenceController: ObservableObject {     static let shared = PersistenceController()     let container: NSPersistentContainer     init(inMemory: Bool = false) {         container = NSPersistentContainer(name: "ReciPlanner")         if inMemory {             container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")         }         container.loadPersistentStores(completionHandler: { (storeDescription, error) in             if let error = error as NSError? {                 fatalError("Unresolved error \(error), \(error.userInfo)")             }         })         container.viewContext.automaticallyMergesChangesFromParent = true     }          func addObject(image: Data){         let context = container.viewContext         let object = Object(context: context) //Error: Thread 7: "An NSManagedObject of class 'Object' must have a valid NSEntityDescription."         object.item = image     }          func contextSave() {         let context = container.viewContext         if context.hasChanges {             do {                 try context.save()             } catch {                 print("**** ERROR: Unable to save context \(error)")             }         }     } } Data Model:
0
0
1k
Jul ’22
Corrupted Project
So I was trying to save an image in core data and created an NSManagedObject Subclass. After doing so I decided I didn't like it so I deleted the files, but now every time I run the project it creates a properties file with an error saying it can't find a UIImage in scope and the file isn't editable so I can't import UIKit. I've tried deleting the file in finder, deleting the whole project and then redownloading it from GitHub, but to no avail. Basically I want it to stop making the subclass every time I run the project. Please help. Thanks!
0
0
942
Jul ’22
Request Reminders Access
So I'm looking to add a button to my app that would create and fill a reminder in the user's Reminders app, but I've found that I first need to request access to the user's Reminders app data. I've also found the way to do that has been changed with iOS 17 as explained here: https://developer.apple.com/documentation/eventkit/ekeventstore/4162273-requestfullaccesstoreminders How do I use this function so that the prompt requesting for access to the user's Reminders app pops up at the launch of the app every time unless they've previously given permission? Also what would be the function to create the reminder once I do have permissions? This is the code ChatGPT gave me to do so, but I just keep getting "Failed to create Reminder URL". func createReminder() { let reminderTitle = "Cocktail Groceries" var subtaskStrings: [String] = [] for ingredient in shoppingList { subtaskStrings.append(ingredient) } let subtasks = subtaskStrings.map { (ingredient) -> [String: Any] in return [ "title": ingredient, "completed": false ] } let reminderData: [String: Any] = [ "title": reminderTitle, "subtasks": subtasks ] if let reminderURL = createURL(for: "x-apple-reminder://", with: reminderData) { UIApplication.shared.open(reminderURL) } else { print("Failed to create Reminder URL") } } Also I intend on expanding this function to the notes app. But im taking one step at a time. Any help would be GREATLY appreciated. Thanks!
0
0
950
Sep ’23