Skip navigation.
 
mlGenerating default values in a bindings controlled Tableview
FROM : Richard Stacpoole
DATE : Fri Apr 15 16:03:10 2005

Hi,

I have a bindings controlled Tableview, and the specification I am
working to call for some default values to be already entered when a
new record is created (not a placeholder but actual data).  My model
contains these:

@interface TaskItem : NSObject {
   NSDate *dueDate;
   NSString *details;
   .....
}

and my set* Accessors:
- (void) setDueDate:(NSDate *)newDate
{
   [newDate retain];
   [dueDate release];
   dueDate = newDate;
}

- (void) setDetails:(NSString *)newDetails
{
   newDetails = [newDetails copy];
   [details release];
   details = newDetails;
}

the init method for the model is (I have removed the dueDate method
calls for simplicity):
- (id) init
{
   self = [super init];
   if (self) {
        [self setValue:@"New Task Item" forKey:@"details"];            }
   return self;
}

i have also tried this init:
- (id) init
{
   self = [super init];
   if (self) {
       [self willChangeValueForKey:@"details"];
       [self setDetails:@"New ToDoItem"];
       [self didChangeValueForKey:@"details"];
   }
   return self;
}

When I click on the "New Task" button, which is bound to insert, an
instance of the model is created (and values can be put in), but the
default values from the init method never appear.  The new row is
completely blank.

I am sure this will be a "Doh!" moment, but does anyone know what I am
doing wrong?

Related mailsAuthorDate
mlGenerating default values in a bindings controlled Tableview Richard Stacpoole Apr 15, 16:03
mlRe: Generating default values in a bindings controlled Tableview mmalcolm crawford Apr 15, 23:34