custom cells

Discussion in 'Mac Programming' started by medasmx, Apr 30, 2009.

  1. medasmx macrumors member

    Joined:
    Nov 9, 2008
    #1
    I am trying to make a simple custom cell program. The code below has a matrix of four square buttons. There is a popupbutton associated with it that is supposed to plug the custom cell into the square button of a matrix. The custom cell I made is just a blue box (simple, to start out with). The program compiles but then says "An uncaught exception was raised
    -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class"

    Below is the code. Thanks for any help or suggestions.

    Code:
    //  myCell.h
    //  asmmatrix5
    
    
    #import <Cocoa/Cocoa.h>
    
    
    @interface myCell : NSView {
    NSBezierPath*myPath;
    }
    
    @end
    //  myCell.m
    //  asmmatrix5
    //
    
    #import "myCell.h"
    
    
    @implementation myCell
    
    -(void)drawInteriorWithFrame:(NSRect)rect inView:(NSView*)theControlView
    {
    myPath=[NSBezierPath bezierPathWithRect:rect];
    NSColor*myColor=[NSColor blueColor];
    [myColor set];
    [myPath fill];
    }
    
    @end
    //  AppController.h
    //  asmmatrix5
    //
    
    #import <Cocoa/Cocoa.h>
    @class myCell;
    
    @interface AppController : NSObject {
    IBOutlet myCell*CVOutlet;
    IBOutlet NSMatrix*myMatrix;
    NSString*adamString;
    }
    -(IBAction)myPopUp:(id)sender;
    @end
    //  AppController.m
    //  asmmatrix5
    
    #import "AppController.h"
    #import "myCell.h"
    
    @implementation AppController
    
    -(IBAction)myPopUp:(id)sender
    {
    adamString=[(NSPopUpButton*)sender titleOfSelectedItem];
    if([adamString isEqualToString:@"one"])
    	[myMatrix putCell:CVOutlet atRow:0 column:0];
    if([adamString isEqualToString:@"two"])
    	[myMatrix putCell:CVOutlet atRow:0 column:1];
    if([adamString isEqualToString:@"three"])
    	[myMatrix putCell:CVOutlet atRow:1 column:0];
    if([adamString isEqualToString:@"four"])
    	[myMatrix putCell:CVOutlet atRow:1 column:1];
    }
    
    @end
    
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You cell class should be a subclass of NSCell, not NSView.
     

Share This Page