PDA

View Full Version : Very basic Objective-C Question




jskidmore
Aug 25, 2008, 12:36 AM
Okay, I am completely new to Objective-C so forgive me.

I am trying to run a command when the MainView is initially loaded, so I figured I would need to override the constructor. I tried overriding init and initWithFrame, but it didn't work.

How can I get a command to run (sendDate = NSDate date;) when the UIView is initially loaded?

Thanks a bunch.



kainjow
Aug 25, 2008, 02:29 AM
If your view is inside a NIB you will need to override initWithCoder, if not just use initWithFrame.

- (id)initWithFrame:(CGRect)frame {
if ([super initWithFrame:frame]) {
// put your initialization stuff here
}
return self;
}

- (id)initWithCoder:(NSCoder *)coder {
if ([super initWithCoder:coder]) {
// put your initialization stuff here
}
return self;
}