<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Custom Table Cells, Bindings and Core Data</title>
	<atom:link href="http://www.timisted.net/blog/archive/custom-cells-and-core-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/</link>
	<description>Cocoa Programming and Other Things</description>
	<lastBuildDate>Mon, 19 Sep 2011 03:07:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Gareth</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-19762</link>
		<dc:creator>Gareth</dc:creator>
		<pubDate>Thu, 25 Aug 2011 20:18:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-19762</guid>
		<description>Update on this. I&#039;m using your Nib file and your EmployeeTableCell and I still get the damned -[EmployeeTableCell setPlaceholderString:]: unrecognized selector sent to instance 0x10016e1f0 message.

The only thing I&#039;m doing differently to yours is setting the custom cell in awakeFromNib, because I&#039;m using a non document based app, so can&#039;t use windowControllerDidLoadNib...

- (void)awakeFromNib {
    // Set next responder for this view so we can intercept delete key presses
    [mainView setNextResponder:self];
    
    // Set up custom cell for table view
    EmployeeTableCell *statusCell = [[EmployeeTableCell alloc] init];
	[statusTableColumn setDataCell:statusCell];
}</description>
		<content:encoded><![CDATA[<p>Update on this. I&#8217;m using your Nib file and your EmployeeTableCell and I still get the damned -[EmployeeTableCell setPlaceholderString:]: unrecognized selector sent to instance 0x10016e1f0 message.</p>
<p>The only thing I&#8217;m doing differently to yours is setting the custom cell in awakeFromNib, because I&#8217;m using a non document based app, so can&#8217;t use windowControllerDidLoadNib&#8230;</p>
<p>- (void)awakeFromNib {<br />
    // Set next responder for this view so we can intercept delete key presses<br />
    [mainView setNextResponder:self];</p>
<p>    // Set up custom cell for table view<br />
    EmployeeTableCell *statusCell = [[EmployeeTableCell alloc] init];<br />
	[statusTableColumn setDataCell:statusCell];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-19759</link>
		<dc:creator>Gareth</dc:creator>
		<pubDate>Thu, 25 Aug 2011 15:58:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-19759</guid>
		<description>Hi Tim,

Thanks for the speedy reply. Appreciate your help. I had thought the same thing, why it is trying to use a placeholder when I haven&#039;t set one up and I&#039;m using a NSCell? However there&#039;s definitely no place holder set.

To check I just added a brand new column to my table, set the binding to clientDictionary and all is ok. But then I change the NSTableColumn type to be my CustomCell class, and it crashes with the setPlaceHolderString error.

It&#039;s just too weird!

Any other ideas?

Thanks again.</description>
		<content:encoded><![CDATA[<p>Hi Tim,</p>
<p>Thanks for the speedy reply. Appreciate your help. I had thought the same thing, why it is trying to use a placeholder when I haven&#8217;t set one up and I&#8217;m using a NSCell? However there&#8217;s definitely no place holder set.</p>
<p>To check I just added a brand new column to my table, set the binding to clientDictionary and all is ok. But then I change the NSTableColumn type to be my CustomCell class, and it crashes with the setPlaceHolderString error.</p>
<p>It&#8217;s just too weird!</p>
<p>Any other ideas?</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Isted</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-19754</link>
		<dc:creator>Tim Isted</dc:creator>
		<pubDate>Thu, 25 Aug 2011 10:41:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-19754</guid>
		<description>Hi Gareth,
Have you set a placeholder string in the xib file? If so, just remove it and all will be fine. The custom cell inherits from &lt;code&gt;NSCell&lt;/code&gt; rather than &lt;code&gt;NSTextFieldCell&lt;/code&gt;. The placeholder string property is only available on &lt;code&gt;NSTextFieldCell&lt;/code&gt;, hence the error you&#039;re seeing.
Tim</description>
		<content:encoded><![CDATA[<p>Hi Gareth,<br />
Have you set a placeholder string in the xib file? If so, just remove it and all will be fine. The custom cell inherits from <code>NSCell</code> rather than <code>NSTextFieldCell</code>. The placeholder string property is only available on <code>NSTextFieldCell</code>, hence the error you&#8217;re seeing.<br />
Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-19737</link>
		<dc:creator>Gareth</dc:creator>
		<pubDate>Wed, 24 Aug 2011 19:22:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-19737</guid>
		<description>Hi Tim,

This is a great tutorial and the clearest I&#039;ve found on this subject. So thank you for that. However! I am having a spot of difficulty despite believing I&#039;ve followed the steps to the letter in my own project.

I get up to the part where you bind to the personDictionary in Interface Builder. I&#039;ve defined personDictionary both in my model and also added the various required functions to the custom managedObject class code. When I run the project, I get the following error and crash:

[CustomCell setPlaceholderString:]: unrecognized selector sent to instance 0x100637f20

If I unbind the personDictionary from the table column or change it back to the NSString firstName, the error goes away.

Do you have any ideas what might be happening or pointers of where to look for problems. This has me stumped!

Appreciate your time.

Thanks,

Gareth.</description>
		<content:encoded><![CDATA[<p>Hi Tim,</p>
<p>This is a great tutorial and the clearest I&#8217;ve found on this subject. So thank you for that. However! I am having a spot of difficulty despite believing I&#8217;ve followed the steps to the letter in my own project.</p>
<p>I get up to the part where you bind to the personDictionary in Interface Builder. I&#8217;ve defined personDictionary both in my model and also added the various required functions to the custom managedObject class code. When I run the project, I get the following error and crash:</p>
<p>[CustomCell setPlaceholderString:]: unrecognized selector sent to instance 0x100637f20</p>
<p>If I unbind the personDictionary from the table column or change it back to the NSString firstName, the error goes away.</p>
<p>Do you have any ideas what might be happening or pointers of where to look for problems. This has me stumped!</p>
<p>Appreciate your time.</p>
<p>Thanks,</p>
<p>Gareth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Costa</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-23</link>
		<dc:creator>Tim Costa</dc:creator>
		<pubDate>Tue, 27 Oct 2009 17:33:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-23</guid>
		<description>Sorry... in step 2 I put some angled brackets which got edited out by the board software.

It should read -(void)set_YourClassName_Dictionary.  Re-add the setter that you removed in Tim&#039;s original tutorial.</description>
		<content:encoded><![CDATA[<p>Sorry&#8230; in step 2 I put some angled brackets which got edited out by the board software.</p>
<p>It should read -(void)set_YourClassName_Dictionary.  Re-add the setter that you removed in Tim&#8217;s original tutorial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Costa</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-22</link>
		<dc:creator>Tim Costa</dc:creator>
		<pubDate>Tue, 27 Oct 2009 17:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-22</guid>
		<description>Tim, thanks for your great tutorial!  Using it I was able to add basic editing to my custom cell.  I thought I would share with everyone else.  It doesn&#039;t move the editor to the proper location visually, but shows how to get the guts of editing working.  Basically, it takes advantage of an NSFormatter subclass, and the fact that we are using dictionaries.

1. I subclassed NSTextFieldCell, rather than NSCell.  (I&#039;m not sure yet how to do this with just NSCell.  In my case I have a name, and some read only metadata about the object I am displaying, so this works fine for me.)

2. Add the following to your NSManagedObject subclass (PersonObject in your example):

-(void)setDictionary
{
	[self setValuesForKeysWithDictionary:aDictionary];
}

3. Subclass NSFormatter with the following methods (these are the minimum required to subclass NSFormatter, according to the documentation)

- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
{
	if (anObject){
		*anObject = [NSDictionary dictionaryWithObject:string forKey:@&quot;name&quot;];
		return YES;
	}
	return NO; // This probably shouldn&#039;t happen...Could be a bindings issue if it does?
}
- (NSString *)stringForObjectValue:(id)anObject
{
    if (![anObject isKindOfClass:[NSDictionary class]])
        return nil;
    return [anObject valueForKey:@&quot;name&quot;]; // This will propagate back to your NSManagedObject subclass, since we created setDictionary.
}
- (NSAttributedString*)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attrs
{
	if (![anObject isKindOfClass:[NSDictionary class]])
        return nil;
    NSAttributedString * anAttributedString = [[NSAttributedString alloc]initWithString: [anObject valueForKey:@&quot;name&quot;]];

	return anAttributedString;
}

4. Add the following to your NSTextFieldCell&#039;s awakeFromNib:
	MyFormatter * aMyFormatter = [[[MyFormatter alloc]init]autorelease];
	[self setFormatter:aMyFormatter];

That should be it, if I didn&#039;t leave out any steps...  I hope this helps someone, and if you spot anything that can be improved in my code, please post a followup!
-Tim</description>
		<content:encoded><![CDATA[<p>Tim, thanks for your great tutorial!  Using it I was able to add basic editing to my custom cell.  I thought I would share with everyone else.  It doesn&#8217;t move the editor to the proper location visually, but shows how to get the guts of editing working.  Basically, it takes advantage of an NSFormatter subclass, and the fact that we are using dictionaries.</p>
<p>1. I subclassed NSTextFieldCell, rather than NSCell.  (I&#8217;m not sure yet how to do this with just NSCell.  In my case I have a name, and some read only metadata about the object I am displaying, so this works fine for me.)</p>
<p>2. Add the following to your NSManagedObject subclass (PersonObject in your example):</p>
<p>-(void)setDictionary<br />
{<br />
	[self setValuesForKeysWithDictionary:aDictionary];<br />
}</p>
<p>3. Subclass NSFormatter with the following methods (these are the minimum required to subclass NSFormatter, according to the documentation)</p>
<p>- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error<br />
{<br />
	if (anObject){<br />
		*anObject = [NSDictionary dictionaryWithObject:string forKey:@"name"];<br />
		return YES;<br />
	}<br />
	return NO; // This probably shouldn&#8217;t happen&#8230;Could be a bindings issue if it does?<br />
}<br />
- (NSString *)stringForObjectValue:(id)anObject<br />
{<br />
    if (![anObject isKindOfClass:[NSDictionary class]])<br />
        return nil;<br />
    return [anObject valueForKey:@"name"]; // This will propagate back to your NSManagedObject subclass, since we created setDictionary.<br />
}<br />
- (NSAttributedString*)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attrs<br />
{<br />
	if (![anObject isKindOfClass:[NSDictionary class]])<br />
        return nil;<br />
    NSAttributedString * anAttributedString = [[NSAttributedString alloc]initWithString: [anObject valueForKey:@"name"]];</p>
<p>	return anAttributedString;<br />
}</p>
<p>4. Add the following to your NSTextFieldCell&#8217;s awakeFromNib:<br />
	MyFormatter * aMyFormatter = [[[MyFormatter alloc]init]autorelease];<br />
	[self setFormatter:aMyFormatter];</p>
<p>That should be it, if I didn&#8217;t leave out any steps&#8230;  I hope this helps someone, and if you spot anything that can be improved in my code, please post a followup!<br />
-Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon Murrison</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-20</link>
		<dc:creator>Gordon Murrison</dc:creator>
		<pubDate>Mon, 22 Jun 2009 16:24:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-20</guid>
		<description>Thank you Tim!

Great tutorial.  Just what I needed to kick start my custom TableView.  Wish I had known about the Managed Object Class Generator before I hand-cranked four classes last week!  Thanks also to Simon Wolf for his non-GC comments - I&#039;m not using GC either (yet).</description>
		<content:encoded><![CDATA[<p>Thank you Tim!</p>
<p>Great tutorial.  Just what I needed to kick start my custom TableView.  Wish I had known about the Managed Object Class Generator before I hand-cranked four classes last week!  Thanks also to Simon Wolf for his non-GC comments &#8211; I&#8217;m not using GC either (yet).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Knopper</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-21</link>
		<dc:creator>Mark Knopper</dc:creator>
		<pubDate>Mon, 11 May 2009 15:24:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-21</guid>
		<description>Thanks for this tutorial and example code. There are very few examples of how to implement transient properties out there - it was useful to see how you used keyPathsForValuesAffectingPersonDictionary.</description>
		<content:encoded><![CDATA[<p>Thanks for this tutorial and example code. There are very few examples of how to implement transient properties out there &#8211; it was useful to see how you used keyPathsForValuesAffectingPersonDictionary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon Wolf</title>
		<link>http://www.timisted.net/blog/archive/custom-cells-and-core-data/comment-page-1/#comment-19</link>
		<dc:creator>Simon Wolf</dc:creator>
		<pubDate>Wed, 22 Apr 2009 10:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.timisted.net/blog/?p=15#comment-19</guid>
		<description>Just what I was looking for, thank you Tim.

A few of things I did differently are below. Two were because I&#039;m not using Garbage Collection.

1. Let the Managed Object Class Generator create Objective-C 2.0 properties so that there was less code around. I then simply changed the UNKNOWN_TYPE to NSDictionary and added the custom getter method.

2. In the getter for the NSDictionary I generated an auto-releasing dictionary with an auto-releasing array:
    return [self dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@&quot;firstName&quot;, @&quot;lastName&quot;, @&quot;department&quot;, @&quot;salary&quot;, nil]];

3. In MyDocument.m I released infoCell:
EmployeeTableCell *infoCell = [[EmployeeTableCell alloc] init];
[peopleTableColumn setDataCell:infoCell];
[infoCell release];</description>
		<content:encoded><![CDATA[<p>Just what I was looking for, thank you Tim.</p>
<p>A few of things I did differently are below. Two were because I&#8217;m not using Garbage Collection.</p>
<p>1. Let the Managed Object Class Generator create Objective-C 2.0 properties so that there was less code around. I then simply changed the UNKNOWN_TYPE to NSDictionary and added the custom getter method.</p>
<p>2. In the getter for the NSDictionary I generated an auto-releasing dictionary with an auto-releasing array:<br />
    return [self dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"firstName", @"lastName", @"department", @"salary", nil]];</p>
<p>3. In MyDocument.m I released infoCell:<br />
EmployeeTableCell *infoCell = [[EmployeeTableCell alloc] init];<br />
[peopleTableColumn setDataCell:infoCell];<br />
[infoCell release];</p>
]]></content:encoded>
	</item>
</channel>
</rss>

