last day (56 days later) » 

4:20 PM
Hi Matthew
 
4:35 PM
Huh it works brilliant!
 
Great. It's a bit easier than just accumulating comments...
So just to check, your entity Deck is a subclass of NSManagedObject, called Deck?
And your ClassSelection entity is likewise of class ClassSelection?
How are those two related?
 
Correct
I have the Deck related in a a Many to One relationship
in that many decks can only have one class
but each class can only have 1 deck
lol i meant
that there can be many decks containing the 1 class
sorry watching masterchef australia at the same time not watching what i am typing sometimes
The deck contains 1 attribute
called deckname
and the ClassSelection has only 1 entity named classnames
both of which are just a string type which I planned on filtering to get the specified things dependent on the situation. The tableview is only one aspect I plan on using the string. I am just trying to present the Class next to the Name so the player can see what is what. The name presents but the classname doesn't and throws the error on that line.
If needed I can add a screenshot of my data model
 
4:59 PM
OK. Thanks. So you need to set the relationship between your newly created ClassSelection object (newObject) and the Deck object (storeDeck). If you create the ClassSelection object first, then pass newObject to the view controller when you segue.
 
Ok this is where I got confused in my self teaching, how exactly do you pass a object between view controllers? I thought that because relationships were set that the objects should automatic store correctly...sorry if this is coming across as incredibly stupid but I just started learning coding/core data about 3 months ago self teaching.
 
No problem. When you define a relationship in the Entity, you are saying that it can have a relationship eg. a Deck can have a relationship to a ClassSelection. But you still need to set the value for that relationship. Just like you have to set the values for other attributes.
To pass between VCs, you will have to add a var to your viewcontroller.swift, of type `ClassSelection?` (make it optional, it's easier):

var class : ClassSelection?
 
I see...so that would mean within a context I need to save a separate "relationship" attribute that saves the object relationship as a object itself? or will the name object actually take the relationship object itself that can be called
so after I set the var class: ClassSelection? I then call that and set the object to pass from view controller to view controller to occur before the segue?
 
Exactly - in the view controller with buttonWarrior add a prepareForSegue method. In that, you can get a reference to the VC you are segueing to, and can set the class var to be newObject. Let me find some sample code.
 
5:15 PM
Thank you i appreciate your patience with me on this! Also was my understanding of setting the relationship right? I just want to make sure I am clear on that part
Also for a model like this is using the app delegate going to be fine or should I be constructing a child to primary store coordinator. In the long run this application is going to communicate with a website I am building and also will be having it checking for updates...Right now it is only going to be doing simple statistics presented with view controller graphs but in the long run it will be a very intricate application that will be presenting animations and many other things
 
Stick with the AppDelegate context for now - adding another context will just confuse things. You can add a child context later when you start coding the website communication.
 
Ok lol reading through hundreds of articles had my head spinning on that
 
As regards your entities/attributes/relationships, I think you should have something like this:

Deck ClassSelection
==== =========
deckname (String) classname (String)
class (ClassSelection) decks (NSSet)

i.e. for the "Deck" entity, the relationship "class" is a property of type ClassSelection. So when you create a new Deck, and you want to link it to the "class" that you would have code like this:

storeDeck.deckname = usersDeckName.text
Sorry, my formatting on that went haywire... I'll try again:
Deck
====
deckname (String)
class (ClassSelection)

ClassSelection
=========
classname (String)
decks (NSSet)
 
5:33 PM
i had to name the ClassSelection relationship under the decks as classSelection because it wont let me use class.
err i meant i had to name is classSelected
 
Yes - my mistake - `classSelected` is good.

As for the segue... Amend the `performSegueWithIdentifier` to pass the newObject as sender:

self.performSegueWithIdentifier("popOver", sender: newObject)

The `prepareForSegue` would look something like this:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "popOver" {
let nextVC = segue.destinationViewController as! DetailViewController // replace with the class of your popover view controller
nextVC.classSelected = sender as! ClassSelection
 
Ok so then after the popover is presented and the name is stored then I would have both objects stored from the popover plus the "relationship"?
 
You will have two objects, and you will have set the relationship between them. The relationship is not something separate from the two objects - it is a property of them.
 
Gotcha
Well thats what I though initially so after the object is passed then the relationship will store when I save the context in the popover and I should be able to call both
 
Yes, but here comes the magic: when you build your table view, you do not need two fetchedResultsControllers. You just need one. In your cellForRowAtIndexPath, you can use the relationship to get the value you need for the detailText:

let listed = frc.objectAtIndexPath(indexPath) as! Deck
cell.textLabel?.text = listed.deckname
cell.detailTextLabel!.text = listed.classSelected.classname
 
5:51 PM
NICE thats what I thought it should be and thats the way it was initially but then I hit all these errors and after reading all the multiple child store coordinators i thought maybe taking a similar approach but that is awesome. So then if i understand everything correctly at this point when I go to create the stats first i need to call the deck object then save the stat to the deck entity as in its own store context on that viewcontroller
Core data is starting to make sense to me now i think
you have been beyond amazing!!!
also explaining how to pass objects and get them has been brilliantly explained :P you should create a blog on this you explain things so well!
 
I hope I've helped a little. I remember going through the same anguish when I started. Feel free to post more to this chat room if you hit any problems. I don't know why they restrict chat for new users - when people are beginning, the chat style is far more effective than the Q&A/comments on the main site.
Good luck with the app.
 
Thank you again!!!
 
You're welcome. Hope you didn't miss too much of MasterChef...
 
Haha no not at all it finished for the year already just watching the previous episodes...i didn't want to know the winner before i started looking at the recipes
if you have never watched it before check it out
these cooks are just home cooks but they literally are on par with some world class chefs
 
6:08 PM
Yes, amazing. I'm more of a Great British Bake-Off fan. But either way, I can't even make scrambled egg, so I just watch in awe...
 
Ah nice another food fan! Food is what I work for I want to have the best food in the world. I actually want to travel to the UK and try Heston's restaurant
 

  last day (56 days later) »