HI,
A bit more on this, firstly the problem seems to be related to the
ImageAndTextCell class and secondly looking at the awakeFromNIB method from
SourceView, ImageAndTextCell is allocated, the property is set, but then it
does nothing with it. I assume that under ARC ImageAndTextCell will be sent a
release or will have been autoreleased?
I’ve posted my version of awakeFromNib, which releases it, since I assume that
[tableColumn setDataCell:imageAndTextCell] retains it.
- (void)awakeFromNib
{
// load the icon view controller for later use
iconViewController = [[IconViewController alloc]
initWithNibName:ICONVIEW_NIB_NAME bundle:nil];
// load the file view controller for later use
fileViewController = [[FileViewController alloc]
initWithNibName:FILEVIEW_NIB_NAME bundle:nil];
// load the child edit view controller for later use
childEditController = [[ChildEditController alloc]
initWithWindowNibName:CHILDEDIT_NAME];
[[self window] setAutorecalculatesContentBorderThickness:YES
forEdge:NSMinYEdge];
[[self window] setContentBorderThickness:30 forEdge:NSMinYEdge];
// apply our custom ImageAndTextCell for rendering the first column's
cells
NSTableColumn *tableColumn = [myOutlineView
tableColumnWithIdentifier:COLUMNID_NAME];
ImageAndTextCell *imageAndTextCell = [[ImageAndTextCell alloc]
initTextCell:@"”];
//***************************************************
[imageAndTextCell setEditable:YES];
[tableColumn setDataCell:imageAndTextCell];
separatorCell = [[SeparatorCell alloc] init];
[separatorCell setEditable:NO];
// add our content
[self populateOutlineContents];
// add images to our add/remove buttons
NSImage *addImage = [NSImage imageNamed:NSImageNameAddTemplate];
[addFolderButton setImage:addImage];
NSImage *removeImage = [NSImage imageNamed:NSImageNameRemoveTemplate];
[removeButton setImage:removeImage];
// insert an empty menu item at the beginning of the drown down
button's menu and add its image
NSImage *actionImage = [NSImage imageNamed:NSImageNameActionTemplate];
[actionImage setSize:NSMakeSize(10,10)];
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil
keyEquivalent:@""];
[[actionButton menu] insertItem:menuItem atIndex:0];
[menuItem setImage:actionImage];
// truncate to the middle if the url is too long to fit
[[urlField cell] setLineBreakMode:NSLineBreakByTruncatingMiddle];
// scroll to the top in case the outline contents is very long
[[[myOutlineView enclosingScrollView] verticalScroller]
setFloatValue:0.0];
[[[myOutlineView enclosingScrollView] contentView]
scrollToPoint:NSMakePoint(0,0)];
// make our outline view appear with gradient selection, and behave
like the Finder, iTunes, etc.
[myOutlineView
setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
// drag and drop support
[myOutlineView registerForDraggedTypes:@[kNodesPBoardType,
// our internal drag type
NSURLPboardType, // single url from pasteboard
NSFilenamesPboardType, // from Safari or Finder
NSFilesPromisePboardType]];
[webView setUIDelegate:self]; // be the webView's delegate to capture
NSResponder calls
[webView setFrameLoadDelegate:self]; // so we can receive any possible
errors
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentReceived:)
name:kReceivedContentNotification
object:nil];
}
——————————————————————————————————————————
Adapted version:
-(void) awakeFromNib
{
IconViewController* myIconViewController;
FileViewController* myFileViewController;
ChildEditController* myChildEditWindowController;
SeparatorCell* mySeparatorCell;
NSTableColumn* tableColumn;
ImageAndTextCell* myImageAndTextCell;
//**
//** Load the Icon and File View Controllers
//**
myIconViewController = [[IconViewController alloc]
initWithNibName:ICONVIEW_NIB_NAME bundle:nil];
self.pIconViewController = myIconViewController;
[myIconViewController release];
myFileViewController = [[FileViewController alloc]
initWithNibName:FILEVIEW_NIB_NAME bundle:nil];
self.pFileViewController = myFileViewController;
[myFileViewController release];
//**
//** Load the Child Edit Window Controller
//**
myChildEditWindowController = [[ChildEditController alloc]
initWithWindowNibName:CHILDEDIT_NAME];
self.pChildEditWindowController = myChildEditWindowController;
[myChildEditWindowController release];
//**
//** Setup the Window
//**
[self.window setAutorecalculatesContentBorderThickness:YES forEdge:NSMinYEdge];
[self.window setContentBorderThickness:30 forEdge:NSMinYEdge];
//**
//** Apply our custom ImageAndTextCell for rendering the first column's cells
//**
tableColumn = [self.pOutlineView tableColumnWithIdentifier:COLUMNID_NAME];
myImageAndTextCell = [[ImageAndTextCell alloc] initTextCell:@""];
[myImageAndTextCell setEditable:YES];
[tableColumn setDataCell:myImageAndTextCell];
//**
//** Setup the Separator Cell
//**
mySeparatorCell = [[SeparatorCell alloc] init];
self.pSeparatorCell = mySeparatorCell;
[mySeparatorCell release];
[self.pSeparatorCell setEditable:NO];
//**
//** Populate the Contents
//**
[self populateOutlineContents];
// truncate to the middle if the url is too long to fit
[[self.pURLField cell] setLineBreakMode:NSLineBreakByTruncatingMiddle];
// scroll to the top in case the outline contents is very long
[[[self.pOutlineView enclosingScrollView] verticalScroller] setFloatValue:0.0];
[[[self.pOutlineView enclosingScrollView] contentView]
scrollToPoint:NSMakePoint(0,0)];
// make our outline view appear with gradient selection, and behave like the
Finder, iTunes, etc.
[self.pOutlineView
setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
// drag and drop support
[self.pOutlineView registerForDraggedTypes:@[kNodesPBoardType,
// our internal drag type
NSURLPboardType, // single url from pasteboard
NSFilenamesPboardType, // from Safari or Finder
NSFilesPromisePboardType]];
[self.pWebView setUIDelegate:self]; // be the
webView's delegate to capture NSResponder calls
[self.pWebView setFrameLoadDelegate:self]; // so we can receive
any possible errors
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(contentReceived:) name:kReceivedContentNotification
object:nil];
[myImageAndTextCell release];
}
Also, ImageAndTextCell implements the copying protocol as so, I’m wondering if
I should self.pTextCellImage to have the copy attribute instead of retain,
although I think this should work with retain?
//
-------------------------------------------------------------------------------
// copyWithZone:zone
//
-------------------------------------------------------------------------------
-(id) copyWithZone:(NSZone*) zone
{
LogIfDave(@"ImageAndTextCell - copyWithZone");
ImageAndTextCell *cell = (ImageAndTextCell*) [super copyWithZone:zone];
cell.pTextCellImage = self.pTextCellImage;
return cell;
}
Thanks again, All the Best
Dave
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]