• 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: loop not running
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >loop not running (From: Amy Heavey <email@hidden>)

  • Prev by Date: non-NSString values in model user info via xcode UI
  • Next by Date: Re: Store a file vs create on the fly?
  • Previous by thread: loop not running
  • Next by thread: non-NSString values in model user info via xcode UI
  • Index(es):
    • Date
    • Thread