Recursive call-back block
Recursive call-back block
- Subject: Recursive call-back block
- From: Mikkel Islay <email@hidden>
- Date: Tue, 10 Apr 2012 16:13:28 +0200
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);
Thanks,
Mikkel
_______________________________________________
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