iOS Method sequence

hervey

macrumors newbie
Original poster
Sep 23, 2009
19
0
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.
 

chbeer

macrumors member
Sep 22, 2008
82
0
Berlin
Can you explain why you are doing it so complicated? Why not simply do everything in one method?
 

drf1229

macrumors regular
Jun 22, 2009
237
0
I think you need to look into NSTimer. An example looks like this:
Code:
NSTimer *t=[NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];

[t fire] //Starts the timer
//And the method...
-(void)onTimer{
//The function

[t invalidate] //Stops the timer...
}
 

dejo

Moderator
Staff member
Sep 2, 2004
15,981
450
The Centennial State
I think you need to look into NSTimer.
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:
Code:
- (IBAction)buttonClicked:(id)sender {
    [self A];
    [self B];
    [self C];
}
 

drf1229

macrumors regular
Jun 22, 2009
237
0
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:
Code:
- (IBAction)buttonClicked:(id)sender {
    [self A];
    [self B];
    [self C];
}
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.
 

hervey

macrumors newbie
Original poster
Sep 23, 2009
19
0
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.

Cheers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.