Re: Yosemite NSCollectionView appropriate for spreadsheet-like view?
Re: Yosemite NSCollectionView appropriate for spreadsheet-like view?
- Subject: Re: Yosemite NSCollectionView appropriate for spreadsheet-like view?
- From: Robert Clair <email@hidden>
- Date: Tue, 03 May 2016 15:47:41 -0400
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 <email@hidden <mailto:email@hidden>>
> To: email@hidden <mailto:email@hidden>
> Cc: email@hidden <mailto:email@hidden>
> Subject: Re: Yosemite NSCollectionView appropriate for
> spreadsheet-like view?
> Message-ID: <email@hidden <email@hidden">mailto:email@hidden>>
> Content-Type: text/plain; charset=utf-8
>
>
>> On May 1, 2016, at 9:06 AM, email@hidden <mailto:email@hidden> 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 (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