Post

Replies

Boosts

Views

Activity

Reply to Read, update and delete
I think I understand the tutorial. That information is useful. Thank you. But I do not know how to apply that to the way to do things in the Insert that I show in the question. If I understand, in that case, they put the context outside the crud, they do not do that in each crud. Only once at the beginning.For instance how to:- Read: how to call the context (lazy var context) and then read all the pairs name - password that the database has.- Update: how to call the context and then update the password for the name John (for instance)- Delete: how to call the context and delete the name John and its password
Feb ’20
Reply to write date in Xcode
- What is the problem:When I click the button insert I get an error:Thread 1: signal SIGABRTIn the console:2020-03-02 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "data"; desired type = NSDate; given type = __NSCFString; value = (Function).' libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)The problem is in this line of code:contingut.setValue("\(today2)", forKey: "data")If I remove the previous line of code and I only use this, it works well. Here I insert the text from the UITextView:contingut.setValue(textForm.text, forKey: "text1")- What do you expect? I just want to safe the date when the user enter the text in a form (UITextView)
Mar ’20
Reply to write date in Xcode
Thank you for your answer.This line of code gives me error:contingut.setValue(Date(), forKey: "dateCreated")I tried to keep the datamodel Attribute Type to String and then change to Date. In both cases, it gives me an errorThen I tried:contingut.setValue("\(Date())", forKey: "dateCreated")In this case, it creates well the date but only if the Type is StringI am confused, what is the right way to do that?
Mar ’20
Reply to write date in Xcode
After trying many things I could find where the problem is. Things go wrong when I change the Type of the Attribute in the .xcdatamodeld The only solution I could find is to create a new project.I cannot even create a new Attribute with a different name. It seems that, I cannot change any Attribute in the .xcdatamodeld. Am I missing anything?
Mar ’20
Reply to Check before the update in Core Data
Thank you for the reference to the videos. I will love to study that.func updateData() is a simple code to create data in Core Data that I found in a tutorial. There is no error there, it is ok. What I miss in that code is a way to check if the value I want to update exists in Core Data.For instance, the example is looking for John. If it finds it, it will change it to John2. But, if in the database there is no John, that will not work, of course. So, I need to add something like the conditional that I put at the beginning. My question is how can I say in that example "if (you find the username John in Core Data) ..."
Mar ’20
Reply to Fade in to second window
I suppose I do not have the necessary level. There are many things I do not understand in your code.Just to begin: if I put the var it gives me an error: "Class 'ViewController' has no initializers"Where should that var be? do you do anything before?class ViewController: NSViewController { var myWindow: NSWindow}
Apr ’20
Reply to Fade in to second window
Sorry, but I still do not understand.Let's say that I create a new project:The first window is ViewController.swiftI put a second View Controller from library. I connect that with SecondViewController.swiftI have button1 in ViewController.swift with segue1 that goes to SecondViewController.swiftI suppose the next step is, if I understand what you say, go to Main.storyboard control drag from SecondViewController to ViewController.swift and create an Oulet. Is that right? But if I amb in storyboard SecondViewController and I open the assistant, it will open the SecondViewController.swift not ViewController.swift. How and where do you make that connection of the window?
Apr ’20