So I was just following along with CodeWithChris's video on make a persistent data storage (https://youtu.be/O7u9nYWjvKk) and I got to the part where he says to include the subclass NSManagedObject to the family and person classes. I have a very similar program with recipe and list of recipes, but when I add "NSManagedObject" I get an error:
< unknown >:0: error: stored property '_title' requires an initial value
CoreData.NSManagedObject:2:12: note: superclass 'NSManagedObject' requires all stored properties to have initial values
open class NSManagedObject : NSObject {
< unknown > :0: error: stored property '_calories' requires an initial value
CoreData.NSManagedObject:2:12: note: superclass 'NSManagedObject' requires all stored properties to have initial values
open class NSManagedObject : NSObject {
etc.
Unsure of how to fix it. Any help would be greatly appreciated.
Code in case I'm missing something
RecipeList:
import Foundation
import CoreData
class RecipeList:NSManagedObject, Identifiable{
@Published var recipeList:[Recipe]
init(){
recipeList=[]
}
func addRecipe(recipe: Recipe){
self.recipeList.append(recipe)
}
func removeRecipe(loc: Int){
self.recipeList.remove(at: loc)
}
func getList() -> Array<Recipe>{
return recipeList
}
}
Recipe:
import Foundation
import UIKit
import CoreData
class Recipe:NSManagedObject, Identifiable{
@Published var title: String
@Published var calories: String
@Published var ingredients: Array<String>
@Published var instructions: Array<String>
@Published var totalTime: String
@Published var notes: String
init(title: String, calories: String, ingredients: Array<String>, instructions: Array<String>, totalTime: String, notes: String){
self.title=title
self.calories=calories
self.ingredients=ingredients
self.instructions=instructions
self.totalTime=totalTime
self.notes=notes
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I would like to implement the “Toolbar” kind of thing above the keyboard shown in the image that includes an up and down arrow to iterate through text fields and a done button to dismiss the keyboard. How do I do this? Thanks!
Anyone have a really good YouTube tutorial on how to implement an image as binary data in core data? Thanks!
I need to share a singular instance of an object created in core data. Every video I've found that showed how to do this used outdated code and I was wondering if anyone had a working way to either create the airdrop button (because I don't even know how to do that yet, or make it so that the data is share is a duplicate of the object from the sharers device. Thanks!
This is the entity that needs to be shared via airdrop:
How has GitHub formatted their navigation bar like this? The title is aligned with the back button and add button, the search bar is inside instead of under, and they have buttons alone the bottom that filter the list. Is there a view object that shortcuts this?
If you understand even one part of that I would appreciate that information. Thanks!
I need a picker exactly like the one in the picture (Apple’s timer app), but without the seconds. I’ve found that this is a UIDatePicker in the .countDownTimer mode. But my program runs on swiftUI instead of UIKit. Is there any way I could still use this or is there a swiftUI version? Thanks!
Anyone have any idea as to how to embed an SwiftUI View in a UITabBarController. From what I understand they were made to contain views made from UIKit and my views are made from SwiftUI so I’m not exactly sure how to use a UITabBarController in the storyboard with the views that I have.
Any help would be greatly appreciated!
Does anyone know the best way to store core data using a calendar? The only way I could think is adding a date attribute and every time the date is changed on the calendar changing the NSPredicate to that date and if there isn’t one creating a new instance with that date as it’s date value. I’m certain this is not the best method, but I couldn’t think of any other, but I know I’m very limited in my SwiftUI knowledge. So any guidance would be greatly appreciated.
For more insight into what I’m looking for see my previous post asking for advice on what to change about my own method: https://developer.apple.com/forums/thread/708915
So I have a TabView in my app and I want to go back yo the main view when that tabItem is pressed. For example, when you open the App Store and go to the games tab, click on a game. It takes you to a navigation link to a new view. You can either go back to the first page by pressing the arrow, or by tapping the “games” tabItem again. I want to be able to press my tabItem in a subview of the same tab to go back to the original view that the tab is assigned to.
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!!
So I have a TabView in my app and I want to go back yo the main view when that tabItem is pressed. For example, when you open the App Store and go to the games tab, click on a game. It takes you to a navigation link to a new view. You can either go back to the first page by pressing the arrow, or by tapping the “games” tabItem again. I want to be able to press my tabItem in a subview of the same tab to go back to the original view that the tab is assigned to.
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!
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!
Given an image selected in a UIImagePickerController and saved as a UIImage, how can I save that image in a core data model using XCode 14 beta? I’ve only found videos from 2 years ago where they make their own persistence file which is outdated.
Any help would be greatly appreciated! Thanks.
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!!