• 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 - setSubEntities doesn't work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: COREDATA - setSubEntities doesn't work


  • Subject: Re: COREDATA - setSubEntities doesn't work
  • From: email@hidden
  • Date: Sun, 5 Feb 2006 23:50:49 -0800

Here's a patch (category) to NSEntityDescription that fixes this:

- (void)setSubentities:(NSArray *)array
{
NSEnumerator *subEntities = [array objectEnumerator];
NSEntityDescription *anEntity = nil;

while ( anEntity = [subEntities nextObject] )
{
NSArray *combinedProperties = [[NSArray arrayWithArray:[self properties]] arrayByAddingObjectsFromArray:[anEntity properties]];

//Dangerous, but we got no other choice
[anEntity->_superentity release];
anEntity->_superentity = self;
[anEntity->_superentity retain];

//Heres the critical part, this is what coredata was not doing that we need to fix the most
[anEntity setProperties:combinedProperties];

//More dangerous, but gotta do this too
[(NSMutableDictionary *)_subentities setObject:anEntity forKey: [anEntity name]];
}
}


In an ideal subclass, I would just call super, then combine the properties.....

Andre
email@hidden



email@hidden wrote:

Hi list,

I'm having trouble with linking two models at runtime, so I have distilled the problem into a model built at runtime, following apple's docs and examples.
Setting the subEntity to another works as far as its name is concerned, but no attributes are inherited...... very.... surprising.


I hope I am doing something stupid, but it looks like maybe not...

Here's a very simple example of an object graph constructed at runtime.
http://homepage.mac.com/son_gohan/ SimpleLinkedModelThatShouldWorkButDoesnt.zip


If your interested, please look at the app delegate and its - managedObjectModel method, this is from the coredata application template from Xcode.

I hope I can find a solution without going to DTS...

Thanks in advance for any info.

Andre
email@hidden



_______________________________________________
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

Andre email@hidden



_______________________________________________
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


References: 
 >COREDATA - setSubEntities doesn't work (From: email@hidden)

  • Prev by Date: RE: Interrogating selectors at runtime
  • Next by Date: Universal Binaries and messages to nil
  • Previous by thread: COREDATA - setSubEntities doesn't work
  • Next by thread: test - please ignore
  • Index(es):
    • Date
    • Thread