On Jul 12, 2014, at 13:50 , Bill Cheeseman <[email protected]> wrote:
> __block id returnItem = nil;
> __block void (^findItemForIdentifierInArray)(NSArray *) = ^(NSArray
> *contents) {
> [contents enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL
> *stop) {
> if ([[obj objectForKey:ID_KEY] isEqualToString:identifier]) {
> returnItem = obj;
> *stop = YES;
> }
> id subarray = [obj objectForKey:CONTENTS_KEY];
> if (subarray) {
> findItemForIdentifierInArray(subarray); // recursive
> }
> }];
> };
>
> findItemForIdentifierInArray([self sourceListContents]);
> return returnItem;
> }
>
> The only remaining problem is that the recursive call to
> findItemForIdentifierInArray() is flagged with a warning that it is likely to
> lead to retain cycles, hence leaks.
I dunno, this sort of thing makes my head hurt too. But I can’t see any
downside to changing this to use a private method and a for loop inside it,
other than having to think of a private method name.
_______________________________________________
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]