One Quickie


Posing as a class (Hacks->General)
Say you wanted to take a peek at how NSSpellChecker does its thing. You can make a subclass, override methods, log interesting stuff, and then send super. Use poseAsClass: to hook yourself into the matrix during the +load method:
@interface BorkSpellChecker : NSSpellChecker
{
}
@end // BorkSpellChecker


@implementation BorkSpellChecker

+ (void) load
{
    NSLog (@"posing");
    [self poseAsClass: [NSSpellChecker class]];

} // load


- (void) ignoreWord: (NSString *) word  inSpellDocumentWithTag: (int) tag
{
    NSLog (@"ignore word: %@  intag: %d",
           word, tag);
    [super ignoreWord: word
           inSpellDocumentWithTag: tag];

} // ignoreWord



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com