On Jan 20, 2011, at 11:48, Amy Heavey wrote: > NSArray *newOrderProducts; > newOrderProducts = [Products selectedObjects]; > NSEnumerator *loop = [newOrderProducts objectEnumerator]; > NSObject *product; > NSLog(@"Hello There!"); > //for each selected product: > while ((product = [loop nextObject])) { > NSLog(@"Hello There! in while loop"); > //create new kitItem > NSManagedObject *newOrderItem = [NSEntityDescription > > > insertNewObjectForEntityForName:@"CustomerOrderItems" > > > inManagedObjectContext:managedObjectContext]; > > //link new product to order > [newOrderItem setValue:order forKey:@"customerOrderRef"]; > //link new order item to product > [newOrderItem setValue:product forKey:@"orderItemProduct"]; > > }
The debugger is your friend here. Your code (apparently) demonstrates that [loop nextObject] is nil the first time through. That might be because the newOrderProducts array is empty. Or it could be that 'loop' is nil, which could be because 'newOrderProducts' is nil, which could be because 'Products' is nil. Your first step is to find out which of those unexpected conditions is true. Once you have the "which", the "why" should follow. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com