I'm reading about binding and KVC/KVO... and I have a question for which I can't seem to find an answer... I'll use a simple example, it'll be easier to explain that way...

Let's say I have a simple class called "File"... my File class has a property called filePath which is an NSString representing the path of that file...

Now, assuming I want to bind an array of those File objects to a Table View, however, what I would like to display in the table's column is not the complete path of the file, but just the file name (that I get with [filePath lastPathComponent])....

What would be the best way to achieve that? Basically: I want to bind my column to a property that doesn't really exist (i.e. only part of the filePath property)...

I did create a method called "- NSString *fileName" which only does this:
return [filePath lastPathComponent];

It seems to work if I bind my table's column to the "arrangedObjects.fileName" model key but I am wondering if it is a good idea to do it like this? Basically the "fileName" method "acts" as if it was the getter of a "fileName" property, but that property doesn't really exist...it just returns a part of my filePath property...

It's a bit harder to explain than I thought it would be but to sum it up: Is it ok to bind my column to a property that is, in fact, not a property but just a method that returns a string... or should I create an actual instance variable "NSString *fileName" with a regular getter and setter....? It seems like there are a lot of cases where the data I want to show in my TableView is not an actual property of my class but a formatted or modified version of it.. Also, keep in mind that the table column is NOT editable so I don't really need a setter...

Any help/suggestions would be appreciated! If I'm unclear let me know I'll try to explain it better!

Jean-Nicolas Jolivet
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to