CocoaDev

Edit AllPages

How do you have that little image by the icon, like in Mail?


I don’t know how the question was aimed at, but I’m pretty sure its an NSBezierPath as a circle in red with a 2 in it. Well, at least thats what I do. – MatPeterson

Actually, I believe it’s an image from within the bundle, with the text applied to it. As for how you apply it to the dock icon, I really don’t recall; you might begin looking in NSApplication’s documentation. – RobRix


Executive summary of the example code below:


Also see BezierPathForDockIconCountBadge


Controller Header

#import <Cocoa/Cocoa.h>

@interface IconImageCounterController : NSObject { NSImage *iconImageBuffer; NSImage *originalIcon; NSTimer *timer; NSDictionary *attributes; int count; }

Controller Source

#import “IconImageCounterController.h”

@implementation IconImageCounterController

}

}

– zootbobbalu

You Rock! -EcumeDesJours


I found a very nice implementation available free here: http://blog.oofn.net/2006/01/08/badging-for-everyone/ –GrahamCox


Here’s my implementation of a dock badge (like Acquisition’s): http://johndevor.wordpress.com/2007/01/17/dock-badging-is-fun/ –JohnDevor


If you’re using Leopard you can do the following:

[[NSApp dockTile] setBadgeLabel:@”1000”];

Check out the source of Transmission – http://www.transmissionbt.com/ , the files Badger and BadgerView, if you need to do custom badge work or support pre-leopard machines.

MatthieuCormier