NSTextField binding returns nil not empty string
NSTextField binding returns nil not empty string
- Subject: NSTextField binding returns nil not empty string
- From: Chris Paveglio <email@hidden>
- Date: Tue, 30 Apr 2013 12:14:23 -0700 (PDT)
What is the best way to handle this? I have a table view (using cell views) which has multiple text fields in it. I have an arrayController that holds an array of the custom objects that hold the data for each tableCellView (row). The array is made in the appDelegate and it always consists of text or empty text strings. It all works great as described.
When I edit the text in the fields, if I remove all the text from one field, it must be returning nil back to the bound object. This messes things up later, because I need to return an empty string for each of the ivars in my custom object, not nil.
So, my way to get around this was to essentially check if the object's ivar was nil, and if so then return empty string when called upon. This works just fine and I think it's efficient enough.
But is there an even better way to handle that? I tried using "null placeholder" in the IB/binding options but that didn't seem to work. The ivars for the custom object aren't set to "strong" and I tried that but that didn't seem to help either. Is there anything I'm missing or does an NSTextField always return "nil" when a value is removed from it, or can I force it to return an empty string?
-------custom object (with ARC):
@interface SpecialObject : NSObject
@property(nonatomic, readwrite) NSString*headline;
...
Thanks, Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden