On Aug 13, 2008, at 6:47 PM, Nathan Gilmore wrote:

Hello everyone,

I am a newbie and I am having trouble getting my setter to work when I use @synthesize. Here is the code:

**Header File**

@interface DayTaskController : NSArrayController {

        NSCalendarDate *searchDate;

}
- (void)search:(id)sender;

@property(readwrite, assign) NSCalendarDate *searchDate;

@end

**Implementation File**
@implementation DayTaskController

@synthesize searchDate;
@synthesize appController;
.
.
.

**AppController**
I try and just set the searchdate field and then output it:

- (id) init
{
        [super init];

        [self setDayOneDate:[NSCalendarDate calendarDate]];
        NSLog(@"self dayOneDate = %@",dayOneDate);
        [dayOneTasks setSearchDate:dayOneDate];
        NSLog(@"dayOneTasks search date = %@", [dayOneTasks searchDate]);
        return self;
}

The above code gives this output:
2008-08-13 21:30:23.081 LifeTask2[20085:10b] self dayOneDate = 2008-08-13 21:30:23 -0400 2008-08-13 21:30:23.082 LifeTask2[20085:10b] dayOneTasks search date = (null)

Any suggestions as to what I am doing wrong?

Thank you!
Nathan


Hi, Nathan!

Have you checked to ensure that dayOneTasks itself is not nil? Also, are you using Garbage Collection? If *not*, then try changing from "assign" to "retain" in your property declaration.

Also, a couple of suggestions: be sure to write your first line as "self = [super init];" (instead of "[super init];" by itself). Additionally, you may wish to consider using the standard property syntax, such as:

dayOneTasks.searchDate = dayOneDate;

NSLog(@"dayOneTasks search date = %@", dayOneTasks.searchDate);


-- instead of using the bracketed accessors. That's one reason, in my opinion, that properties are a good idea -- they can simplify syntax and/or improve readability for certain cases.

Cheers,
        Andrew

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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