Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jskidmore

macrumors newbie
Original poster
Jul 13, 2008
4
0
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

Moderator emeritus
Jun 15, 2000
7,958
7
If your view is inside a NIB you will need to override initWithCoder, if not just use initWithFrame.

Code:
- (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;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.