• 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
New ManagedObject with relationship problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New ManagedObject with relationship problem


  • Subject: New ManagedObject with relationship problem
  • From: Baron Stephane <email@hidden>
  • Date: Wed, 25 Oct 2006 22:20:16 +0200

I try to add an new entity by code

this entity have one reverse relationship, one to many

i have an entity item and an entity client

one item can have one client
a client can have many item

when i create the entity the log are fine for me
(i have no relationship fault message)

here is the nslog for the new entity:

2006-10-25 22:06:17.361 itemCD[1018:117] <NSManagedObject: 0x3edb30> (entity: item; id: 0x3e7c20 <x-coredata:///item/t111736DC-4BD4-43BE-9E23-A5F561AC53282 > ; data: {
client = 0x304c90 <x-coredata://95879A34-20D6-4516-AE57-A255C666849C/Client/p106 >;
nameOfItem = "New Item";
prestations = ();
tva = 19.6;
})


the client selected is correctly set in the new entity

when i try to add the new entity to coredata i got this message:

2006-10-25 22:06:17.363 itemCD[1018:117] Cannot create NSSet from object <Client: 0x3dd890> (entity: Client; id: 0x304c90 <x-coredata://95879A34-20D6-4516-AE57-A255C666849C/Client/p106 > ; data: {
adresse1 = "";
adresse2 = "";
codePostal = "";
isSociete = 0;
items = (0x3e7c20 <x-coredata:///item/t111736DC-4BD4-43BE-9E23-A5F561AC53282 >);
nom = ertert;
nomPrenom = "ertert ";
prenom = "";
societe = "";
ville = "";
}) of class Client



I don't understand what i am doing wrong, i have tryed to use mutableSetValueForKey without succes or creating an NSSet and using setValue:myNSSet before the addObject method without success



here is my code: can someone tell where i am wrong ?? Thanks


NSManagedObject *newItem = [NSEntityDescription insertNewObjectForEntityForName:@"item" inManagedObjectContext: [self managedObjectContext]];
[newItem setValue:[fieldName stringValue] forKey:@"nameOfItem"];
[newItem setValue:[[arrayOfClients selectedObjects] objectAtIndex:0] forKey:@"client"]; <--- the relationship


NSString *valueTVA=[[popUpTVA selectedItem]title];
NSDecimalNumber *myTVA=[NSDecimalNumber decimalNumberWithString:valueTVA];


[newItem setValue:myTVA forKey:@"tva"];

[arrayOfItems addObject:newItem];

arrayOfItems and arrayOfClients are NSArrayController



_______________________________________________
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


  • Prev by Date: Re: Re: NSTimer question: How to fire at second 00, 05, 10 etc ?
  • Next by Date: Re: NSTask stealth bug in readDataOfLength!! :(
  • Previous by thread: binding example for NSComboBox needed
  • Next by thread: NSFileWrapper contents?
  • Index(es):
    • Date
    • Thread