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 (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

Reply via email to