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

Michael H

macrumors newbie
Original poster
Jan 26, 2008
22
0
:confused: Error & Warning fixed, however when I Build & Go app loads ok but flipToSecond method doesn't seem to be called. I placed an NSLog in flipToSecond method to check if it is being called NO LUCK.

Code:
-(void) applicationDidFinishLaunching : (UIApplication *) application {
	
	timer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target:self selector:@selector(flipToSecond:) userInfo:nil repeats: NO]; // change YES to NO

}

//define the targetmethod

- (void) flipToSecond: (NSTimer *) timer {
		
	NSLog(@"flipToSecond was successful!");
	
}

Last line in console is:

Pending breakpoint 1 - "objc_exception_throw" resolved
(gdb)

Can't seem to figure it out. Help Please.
 
Do you get any warnings when compiling? What does the debugger show when it breaks on the exception?
 
Non-repeating timing actions can usually be more simply implemented with performSelector:withObject:afterDelay:
 
timer declared in .h file

Code:
#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController {

	NSTimer *timer;
	
}

@property (nonatomic, retain) NSTimer *timer;


@end

Debugger indicates build successful.

Am I missing something on starting the loop?
 
THANKS so much everyone for your help.

-(void)viewDidLoad {

[self performSelector: @selector(flipToSecond:) withObject: nil afterDelay: 3.0];

[super viewDidLoad];
}

Used performSelector instead of NSTimer and placed it in viewDidLoad instead of applicationDidFinishLaunching.

I've learned a lot from everyone and again thank all of you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.