Re: loop not running
Re: loop not running
- Subject: Re: loop not running
- From: Quincey Morris <email@hidden>
- Date: Thu, 20 Jan 2011 12:13:21 -0800
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 (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