On Dec 11, 2008, at 9:21 AM, Jean-Daniel Dupas wrote:


Le 11 déc. 08 à 17:55, rajesh a écrit :

Hi All,

I implemented NStableView which contains few "columns" with NSImageCells , there are huge number of rows ( for the nightmare ) images are requested over the network and hence images are never readily available.

but part of my framework intimates me whenever an image is downloaded and i precisely know for which of the rows image has been downloaded.( so far good ).

I am trying to register an observer in the custom cell class of the ImageCell I mentioned.

So whenever display is requested on the cell , it checks for the image in downloads , if it isn't available it draws empty image else it places an request and waits for the image.
After image is downloaded observer tries to invoke the drawing again.

This way only cells which are actually in "screen display" get drawn , hence I am supposing there would less traffic and leads to efficient drawing.

Is this a right practice ? or completely unethical ?

Thanks
Rajesh


Did you try to simply use a table view data source and the built-in optimization mechanism before trying to do such complex things ? For example, NSScrollView, and so NSTableView (which are generally embedded in scrollview) only draw the visible part, and ask data source only the visible value.

So write a simple data source that returns the image or nothing if it is not available in the -getValue.... method.

This will work, and it sounds like what rajesh is proposing.

The disadvantage of this approach is that type selection will attempt to load a preparedCellAtColumn:row: -- that includes touching off - willDisplayCell and -objectValue, which will cause the datasource to unnecessarily load the image.

There are two easy work arounds to avoid that performance problem:
1. Turn off type selection: setAllowsTypeSelect:NO
2. Implement the delegate method:

- (NSString *)tableView:(NSTableView *)tableView typeSelectStringForTableColumn:(NSTableColumn *)tableColumn row: (NSInteger)row AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

corbin


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to