• 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
Re: CoreData relationships in IB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData relationships in IB


  • Subject: Re: CoreData relationships in IB
  • From: T Reaves <email@hidden>
  • Date: Sun, 22 May 2005 17:51:27 -0400


On May 22, 2005, at 4:41 PM, mmalcolm crawford wrote:


On May 22, 2005, at 1:22 PM, T Reaves wrote:

On May 22, 2005, at 3:12 PM, mmalcolm crawford wrote:

It does not appear that CoreData and the object controllers can instantiate the instance of ObjectB when objectB.field is set. Is this correct?

In what sense do you mean objectB.field is set?

I mean that I have a text field bound to selection.objectB.someValue of a given array controller that is representing a CoreData entity. I then compile the application, run it, and enter some value into the text fields. I then exit the application.


OK...



Do I have to go ahead and create .h & .m files for my objects, and do the initialization of the contained objects there? Or is there a way to set this up in CoreData nd IB?

I'm not sure what is the relevance of the .h and .m files?

    If CoreData/IB


I'm not sure why IB is relevant? Is this something you also want to happen in IB's Test Interface mode?


does not know how to instantiate an instance of the contained object (ObjectA contains an instance of ObjectB), then I would have to create ObjectA.h & ObjectA.m, and in the init method (or somewhere equivalent), I would have to programatically create an instance of ObjectB and set it to the instance variable in ObjectA like:
init
{
objectB = [ObjectB new];
}



If all you've done is bound a text field's 'value' to a property of objectB, I'm not sure why you'd expect an instance of ObjectB to be created automatically if none exists?
Just as you would if Core Data and bindings were not involved, you still have to instantiate variables... A further issue here, though, is ObjectA a subclass of NSManagedObject? If so, you cannot simply create an instance with 'new' -- it must be inserted into the managed object context etc...



What I'm wanting to do is very common; so common, I thought that perhaps Apple would have added functionality to support it. CoreData requires changes to IB as well as the actual CoreData libraries. Else, an array controller would not ask you if you wanted to bind to an Entity, or what managedContext to bind to. CoreData is not simply CoreData. There are a lot of things that go with it. Hence my reference to IB, and its relevance.


It would not have been too difficult to have added another item in IB's inspector that said 'Create referenced/contained object if nil' or some-such. Needing to manually create contained objects is not bad, but it does increase the amount of work the developer has to do.

I do believe that I can create an instance in the managed object context etc. simply by sending the 'new' message via polymorphism.

    Thanks for your time.

_______________________________________________
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: CoreData relationships in IB
      • From: mmalcolm crawford <email@hidden>
References: 
 >CoreData relationships in IB (From: T Reaves <email@hidden>)
 >Re: CoreData relationships in IB (From: mmalcolm crawford <email@hidden>)
 >Re: CoreData relationships in IB (From: T Reaves <email@hidden>)
 >Re: CoreData relationships in IB (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: CoreData relationships in IB
  • Next by Date: Subclassing NSManagedObject
  • Previous by thread: Re: CoreData relationships in IB
  • Next by thread: Re: CoreData relationships in IB
  • Index(es):
    • Date
    • Thread