Method sequence

Discussion in 'iOS Programming' started by hervey, Dec 5, 2009.

  1. macrumors newbie

    Sep 23, 2009
    Three methods are called by a single UIButton, methods:A, B, and C. A is called on touchDown, B and C on touchUpInside. A is calculations used in method B, C pushes another viewController onto screen, displaying A and B's calculations. Everything works individually and sometimes together.

    What are some strategies to make the sequence more reliable. NSTimer is possible but seems like a lot of code when I already have to much code.

    I am new to Cocoa and would appreciate any direction.
  2. macrumors member


    Sep 22, 2008
    Can you explain why you are doing it so complicated? Why not simply do everything in one method?
  3. macrumors regular


    Jun 22, 2009
    I think you need to look into NSTimer. An example looks like this:
    NSTimer *t=[NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
    [t fire] //Starts the timer
    //And the method...
    //The function
    [t invalidate] //Stops the timer...
  4. Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    I think chbeer has it right. It all sounds over-complicated. Have touchUpInside call one method, which can then go ahead and call the other three. Something like this:
    - (IBAction)buttonClicked:(id)sender {
        [self A];
        [self B];
        [self C];
  5. macrumors regular


    Jun 22, 2009
    Maybe, but if he wanted the events to be timed so he can put some sort of pause between each action NSTimer would be nice to know. It still would be a good idea to call them like that though.
  6. thread starter macrumors newbie

    Sep 23, 2009
    I hear the chorus and will rework to minimize the number of methods. There are 18 methods on view #1, including the A,B,C mentioned previous. I did have things more centralized a long while back, but had a few problems (especially with the 2 SQL methods) that were solved by compartmentalization.

    I am new to programing, and have spent a lot of time reading the docs about many things. It has been easy for me to get lost in the code.

    The program is an aviation flight planner. It has a database of all the airports in the world that can be used by a turbojet aircraft, and includes the probable wind between any of these points based on the time of the year.

    The user can select an aircraft, date and time for arrival -or- departure, and the appropriate date time is calculated, including Daylight Savings and Time Line issues.

    Many of the components are working and my current challenge is to integrate them into a single program.

    I thank everyone for their suggestions and will post whatever solution to this part of the puzzle.


Share This Page