• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Displaying Core Data using Cocoa binding programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying Core Data using Cocoa binding programmatically


  • Subject: Displaying Core Data using Cocoa binding programmatically
  • From: "Bill So" <email@hidden>
  • Date: Fri, 12 May 2006 18:50:22 +0800

Dear all,

I've got a problem about creating and displaying stuff using Core Data
and Cocoa Binding.

The situation is pretty simple:

- Created a core data cocoa application project (not nspersistentdocument type)

- Created a custom controller and make it the delegate object of the
application.

- implemented the "awakeFromNib" method in the custom controller

the awakeFromNib function will programmatically create some
NSManagedObject.  The code is as follow:

myObj = [NSEntityDescription
insertNewObjectForEntityForName:@"Account"
inManagedObjectContext:[appDelegateObj managedObjectContext]];

[myObj setValue:@"testing" forKey:@"id"];
[myObj setValue:@"peter" forKey:@"first_name"];
[myObj setValue:@"jackson" forKey:@"last_name"];

[[self managedObjectContext] save:&error];

However, the data is not displayed in the GUI.  I m using
NSArrayController and bind it to a NSTableView.  The array
controllers' managedObjectContext is bound to the application delegate
and "automatically prepare content" is checked.

According to Core Data documentation (
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdBindings.html
), the runtime should read data from CoreData stack after running
awakeFromNib and windowControllerDidLoadNib:

If I didn't interpret the doc wrongly, the Cocoa Binding should fetch
data from Core Data after awakeFromNib is called.

Do I have to use addObject in NSArrayController instead of using
insertNewObjectForEntity?

Should I call any function to notify NSArrayController to fetch the
content again??

Please kindly advise.

Thanks for your help!

Bill
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Displaying Core Data using Cocoa binding programmatically
      • From: George Orthwein <email@hidden>
  • Prev by Date: Re: Key-Value Coding Limitations
  • Next by Date: Ipod integration
  • Previous by thread: Re: Implementing Quit
  • Next by thread: Re: Displaying Core Data using Cocoa binding programmatically
  • Index(es):
    • Date
    • Thread