• 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
NSOperationQueue and for-loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOperationQueue and for-loop


  • Subject: NSOperationQueue and for-loop
  • From: Koen van der Drift <email@hidden>
  • Date: Tue, 02 Oct 2012 17:49:51 -0400

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

  • Follow-Ups:
    • Re: NSOperationQueue and for-loop
      • From: email@hidden
  • Prev by Date: Re: ArrayController cannot sort
  • Next by Date: Re: NSOperationQueue and for-loop
  • Previous by thread: Re: ArrayController cannot sort
  • Next by thread: Re: NSOperationQueue and for-loop
  • Index(es):
    • Date
    • Thread