Setting up relationship via drag and drop
Setting up relationship via drag and drop
- Subject: Setting up relationship via drag and drop
- From: Jokke Heikkila <email@hidden>
- Date: Mon, 17 Sep 2007 13:19:58 +0300
I'm cooking up a CD app in which I want to set up 'work order -
customer' relationship with drag and drop. I've tried and looked over
and over again but I always end up with an error
'2007-09-17 08:54:19.853 Verstas[20297] *** -[customerMO
copyWithZone:]: selector not recognized [self = 0x34cba0]'
On the actual d&d operation I seem to have everything ok (according
to the log statements) up to the point where the actual relationship
is setup with [[selectedObjects objectAtIndex:i] setValue:object
forKey:@"customer"];. As the error hints to me there's something
funky in my customerMO class but I really can't figure what to
exactly look for. Though I have subclassed the customerMO this error
happened even though the class was instance of NSManagedObject. Below
is the drag and drop operation which leads to the above error.
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString *newURI = [pb stringForType:NSStringPboardType];
NSLog(@"newURI: %@", newURI);
NSArray *selectedObjects = [orderArray selectedObjects];
unsigned int i, count = [selectedObjects count];
//we need the managed object context and coordinator
NSManagedObjectContext *context = [orderArray managedObjectContext];
NSPersistentStoreCoordinator *coordinator = [context
persistentStoreCoordinator];
for (i=0 ; i < count ; i++) {
NSLog(@"setting new relationship with orderNo %@",
[[selectedObjects objectAtIndex:i] valueForKey:@"workOrderId"]);
NSURL *url = [NSURL URLWithString:newURI];
NSManagedObjectID *objectID = [coordinator
managedObjectIDForURIRepresentation:url];
id object = [context objectWithID:objectID];
NSLog(@"On the other end of relation is %@", [object
valueForKey:@"lastName"]);
[[selectedObjects objectAtIndex:i] setValue:object
forKey:@"customer"];
}
return YES;
}
TIA
-jokke h.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden