1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Very basic Objective-C Question

Discussion in 'iPhone/iPad Programming' started by jskidmore, Aug 24, 2008.

  1. macrumors newbie

    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.
  2. Moderator emeritus


    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;

Share This Page