0

Following a guide on the Apple Core Data I deployed my application to the two table view. The first creates the group of holidays, the second includes all the festivities of the group previously created. The technique is one of the bindings. The tables view are connected to two Array Controller. The first Array Controller manages the entity of the group of holidays, the second manages the entity of individual festivals and has two attributes: name and dates. Now I need to get the dates contained in the Array to use in the application. What is the easiest way?

Andrea
  • 427
  • 3
  • 16

1 Answers1

1

Without following the tutorial myself I can't actually comment on your implementation but I can comment generally.

Perhaps you want to itterate over the selectedObjects?

    // When bound to a row, 1 object = 1 row
    for (Entity *entity in arrayController_.selectedObjects) {
        // Use your entity here ie:
        NSLog(@"The entity's date is %@", entity.date);
    }

Alternatively you can bind a value to the objectValue of the TableCellView

1. Select the TableCellView
2. Add a label
3. Bind the value of the new label to the TableCellView
4. Set the Model Key Path to 'objectValue.date' 

Hope this helps

Matt Melton
  • 2,493
  • 19
  • 25
  • Thanks for the reply. I tried adding your code but I get compile errors, I'm sure I'm wrong. My entity is called "FesteGruppo"and the attribute is called "date". How can I adapt your code? – Andrea Apr 24 '12 at 18:24
  • 1
    Have you included the entity header in the object file, ie: at the top of your .m file you should have `#import "FesteGruppo.h"`? The for loop should be something like `for (FesteGruppo *festeGruppoEntity in ...)` – Matt Melton Apr 25 '12 at 11:00
  • Hello, I did as you said and the situation has improved, but there's still a compile error: Use of undeclared identifier "arrayController_" did you mean "NSArrayController"? How can I fix this? – Andrea Apr 25 '12 at 11:23
  • 1
    When you create an object in Interface Builder that object exists only within the scope of the XIB file. To access it you need to make an IBOutlet and connect it. In your .h file create an ivar along of the lines of: `IBOutlet NSArrayController *arrayController_;`, in Interface Builder CTRL-drag the Array Controller to the `Files Owner`, selecting this outlet. Checkout [Youtube](http://www.youtube.com/watch?v=-EpTGOcC0Jw) too! – Matt Melton Apr 25 '12 at 11:35