Re: Issue with -[NSOutlineView autosaveExpandedItems] - SOLVED
Re: Issue with -[NSOutlineView autosaveExpandedItems] - SOLVED
- Subject: Re: Issue with -[NSOutlineView autosaveExpandedItems] - SOLVED
- From: Quincey Morris <email@hidden>
- Date: Sat, 12 Jul 2014 14:52:28 -0700
On Jul 12, 2014, at 13:50 , Bill Cheeseman <email@hidden> 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@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