Re: iTunes user rating
Re: iTunes user rating
- Subject: Re: iTunes user rating
- From: Alexander Griekspoor <email@hidden>
- Date: Wed, 24 May 2006 00:09:51 +0200
Hmm, worked perfect for me... I do use bindings do in combination
with an array controller. This was all I needed to do:
// Set rating cell
SFHFRatingCell *starCell = [[SFHFRatingCell alloc] initImageCell:
[NSImage imageNamed: @"star"]];
[starCell setContinuous: YES];
[starCell setHighlightedImage: [NSImage imageNamed:
@"star_highlighted"]];
[starCell setPlaceholderImage: [NSImage imageNamed:
@"star_placeholder"]];
[starCell setHighlightedPlaceholderImage: [NSImage imageNamed:
@"star_placeholder_highlighted"]];
[starCell setMaximumRating: [NSNumber numberWithInt: 5]];
NSTableColumn *ratingColumn = [libraryTableView
tableColumnWithIdentifier:@"rating"];
[ratingColumn setDataCell:starCell];
[ratingColumn bind:@"value" toObject: papersController
withKeyPath:@"arrangedObjects.rating" options:nil];
[ratingColumn setSortDescriptorPrototype: [[[NSSortDescriptor alloc]
initWithKey: @"rating" ascending: NO] autorelease]];
oh, and yes I added support for a placeholder image in a subclass
(nothing more than a little dot if no star is present at a position,
and only if the row is selected). No clue where things go wrong in
your case though, sorry.
Alex
On 24-mei-2006, at 0:01, Alan Smith wrote:
I have downloaded and implemented SFHFRatingCell. My code:
in - (void)awakeFromNib
SFHFRatingCell *starCell = [[SFHFRatingCell alloc] initImageCell:
[NSImage imageNamed: @"star.tif"]];
[starCell setContinuous: YES];
[starCell setHighlightedImage: [NSImage imageNamed:
@"star_highlighted.tif"]];
[starCell setMaximumRating: [NSNumber numberWithInt: 5]];
[[pluginTable tableColumnWithIdentifier: @"rating"] setDataCell:
starCell];
[starCell release];
Works fine. My code for setting the value of the cell:
'stars' is an id object.
NSString *identifier = [aTableColumn identifier];
//If the user is trying to set the on/off of the plugin, go
ahead, allow it
if ([identifier isEqualToString:@"onOff"])
{
pluginClass *plugin = [tableItems objectAtIndex:rowIndex];
[plugin takeValue:anObject forKey:identifier];
}
else if ([identifier isEqualToString:@"rating])
{
stars = anObject;
}
Code for displaying the cell:
if ([[aTableColumn identifier] isEqualToString:@"menu"])
{
[aCell setObjectValue:stars];
}
That's it. It displays fine but if I switch from my app to another app
and back again, it crashes and gives a SIGBUS error. I'm missing
something but I don't know what. If only there was some documentation
with SFHFRatingCell.
Thanks, Alan
On 5/21/06, Alexander Griekspoor <email@hidden> wrote:
Hi, coincidentally I wanted to implement an iTunes rating indicator
today as well, and all of this has already been done by Buzz
Andersen.
He also shows how to prevent column dragging, works awesome:
http://www.scifihifi.com/cocoalicious/
BSD license, thanks a bunch Buzz!!!
Cheers,
Alex
*********************************************************
** Alexander Griekspoor **
*********************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
E-mail: email@hidden
AIM: email@hidden
Web: http://www.mekentosj.com
EnzymeX - To cut or not to cut
http://www.mekentosj.com/enzymex
*********************************************************
*********************************************************
** Alexander Griekspoor **
*********************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
AIM: email@hidden
E-mail: email@hidden
Web: http://www.mekentosj.com
4Peaks - For Peaks, Four Peaks.
2004 Winner of the Apple Design Awards
Best Mac OS X Student Product
http://www.mekentosj.com/4peaks
*********************************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden