Model your spread sheet on a (hypothetical 2-D)TableView. Maintain a pool of 
cells starting with enough to cover the view at the default size plus a bit of 
margin. As cells scroll off the view return them to the pool;  as you need new 
ones get them from the pool. If the pool is empty you allocate a new one. It’s 
a bit complicated - you have to keep track of the scrolling in two directions 
and have to account for anything else that changes which cells are visible. But 
I’ve done it and it works. Unfortunately it was for a commercial client and I 
no longer have the code so I can’t share it.

…Robert

> 
> Message: 1
> Date: Tue, 03 May 2016 11:53:16 -0700
> From: Jens Alfke <j...@mooseyard.com <mailto:j...@mooseyard.com>>
> To: thatsanicehatyouh...@me.com <mailto:thatsanicehatyouh...@me.com>
> Cc: cocoa-dev@lists.apple.com <mailto:cocoa-dev@lists.apple.com>
> Subject: Re: Yosemite NSCollectionView appropriate for
>       spreadsheet-like view?
> Message-ID: <f62fb2ae-4f2b-4503-9d37-026336939...@mooseyard.com 
> <mailto:f62fb2ae-4f2b-4503-9d37-026336939...@mooseyard.com>>
> Content-Type: text/plain;     charset=utf-8
> 
> 
>> On May 1, 2016, at 9:06 AM, thatsanicehatyouh...@me.com 
>> <mailto:thatsanicehatyouh...@me.com> wrote:
>> 
>> As I've been thinking about this problem it occurred to me that the new(ish) 
>> NSCollectionView might be a viable replacement in this case. Before I go 
>> down the rabbit hole, is it reasonable to use to create a spreadsheet-like 
>> view?
> 
> No, because it eagerly creates a view for every item in the collection. So if 
> you have a spreadsheet with 100,000 cells, it’s going to create 100,000 
> NSViews when the window opens.
> 
> NSMatrix may work better because it uses only a single view, but IIRC it 
> still preallocates an NSCell for every item. Also I think it’s been 
> deprecated.
> 
> I suspect you’ll need a custom view that uses cells or some other 
> lightweight-view design pattern to avoid consuming resources for items that 
> aren’t currently visible. (Of course, someone else may have already 
> implemented that custom view, either as open source or commercially.)
> 
> —Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to