• 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: Recursive call-back block
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursive call-back block


  • Subject: Re: Recursive call-back block
  • From: Fritz Anderson <email@hidden>
  • Date: Tue, 10 Apr 2012 10:50:14 -0500

On 10 Apr 2012, at 9:13 AM, Mikkel Islay wrote:

> Hello,
>
> The (prototype) code below updates a number of objects of a NSManagedObject-sublass (Progenitor) from a remote host. As the number of objects to update is unknown I would like to use a call-back passed to the updater class invoked by startParserWithObjectId: completionBlock: to recursively call returnblock on the next progenitor-object, so serially, when the update-task has completed.
>
> However, the static analyser gives me the warning : "Variable 'returnblock' is uninitialized when captured by block". It is unclear to me how to interpret the message. Can anyone shed light on it?
>
>    NSEnumerator __block *collectionEnum = [progenitors objectEnumerator];
>    Progenitor *firstProgenitor = [collectionEnum nextObject];
>
>    void (^returnblock)(Progenitor *) = ^(Progenitor *aProgenitor) {
>        if (aProgenitor == nil)  return;
>       	CellUpdater *aCellUpdater = [[CellUpdater alloc] init];
>        [aCellUpdater setThisPersistentStoreCoordinator:thisPersistentStoreCoordinator];
>
>        [aCellUpdater startParserWithObjectId:[aProgenitor objectID] completionBlock:^(NSManagedObjectID *anID) {
>           	[[NSNotificationCenter defaultCenter] postNotificationName:@"updateExistsForProgenitor" object:anID];
>            returnblock([collectionEnum nextObject]);
>         }];
>    };
>
>   returnblock(firstProgenitor);

The block literal [ ^(Progenitor *aProgenitor) { ... ] is created first. Then the address of the created block is assigned to returnblock. But returnedblock is referenced in the block, before the assignment to returnblock gives it a value.

	— F


_______________________________________________

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: 
 >Recursive call-back block (From: Mikkel Islay <email@hidden>)

  • Prev by Date: Cannot autosave a TableView without headers
  • Next by Date: Re: How to bind to NSMutableArray that may contain zero objects?
  • Previous by thread: Recursive call-back block
  • Next by thread: How to set the foreground and background colors of selected text in a field editor (NSTextView)?
  • Index(es):
    • Date
    • Thread