Hi,

When looking how to implement an NSOperationQueue with a loop, I found several 
examples that have the following structure:

        NSInteger  i;

            for ( i = 0; i < 1000; i++ ) {
                [queue addOperationWithBlock:^{
                    i += 1;
                }];
            }

But I get a compiler error:  Variable is not assignable (missing __block type 
specifier)

I solved by declaring the declaration for i:  

        NSInteger __block i;

But why does it work in the examples I found?

Thanks,

- Koen.







_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to