loop not running
loop not running
- Subject: loop not running
- From: Amy Heavey <email@hidden>
- Date: Thu, 20 Jan 2011 19:48:08 +0000
I've got the following code that is almost identical to code I've got
in another app. The other app works, this one doesn't. The only
difference between the two is the variable names;
- (IBAction)addItemsToOrder:sender;{
NSObject *order;
order = [[Orders selectedObjects] objectAtIndex:0];
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"];
}
}
When I run this in the app, I see the first "Hello There" but nothing
else in the log. There is definitely a Products order array in the
interface, and it definitely has selected objects. I have table
columns bound to the Products array so I can see they are selected.
I've got the following in my header file as well;
IBOutlet NSArrayController *Products;
But I just can't see why it's not going into the loop?
Many Thanks
Amy
_______________________________________________
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