tags:

views:

46

answers:

2

Hi, I want to call the method after particular time only one time therefore i was written an statement as following.

    imageAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector([self imageViewAnimation:imageViewObject]) userInfo:nil repeats:NO];

Above won't be worked. Why? It give me some strange problem. How i calling and sending arguments along-with it using NSTimer:scheduledTimerWithTimeInterval:target:selector:userinfo:repeats:

#0  0x02911732 in __kill ()
#1  0x02911724 in kill$UNIX2003 ()
#2  0x029a498d in raise ()
#3  0x029baa44 in abort ()
#4  0x0330bfda in __gnu_cxx::__verbose_terminate_handler ()
#5  0x02ccd61c in _objc_terminate ()
#6  0x0330a17a in __cxxabiv1::__terminate ()
#7  0x0330a1ba in std::terminate ()
#8  0x0330a2b8 in __cxa_throw ()
#9  0x02ccd3d8 in objc_exception_throw ()
#10 0x02bb4a5b in -[NSObject doesNotRecognizeSelector:] ()
#11 0x02b31676 in ___forwarding___ ()
#12 0x02b30a32 in __forwarding_prep_1___ ()
#13 0x000055af in -[StageOneForSuspectOne imageViewAnimation:] (self=0x6182a70, _cmd=0x6fda, imageView=0x618c570) at /Users/ajm/Desktop/ProgramOne/Classes/StageOne.m:218
#14 0x0004cffd in __NSFireTimer ()
#15 0x02b027dc in CFRunLoopRunSpecific ()
#16 0x02b018a8 in CFRunLoopRunInMode ()
#17 0x0352289d in GSEventRunModal ()
#18 0x03522962 in GSEventRun ()
#19 0x002d1372 in UIApplicationMain ()
#20 0x000028ec in main (argc=1, argv=0xbffff074) at /Users/ajm/Desktop/DetectiveJone/main.m:14
(gdb) 
+1  A: 

Your selector is defined incorrectly.

imageAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(imageViewAnimation:) userInfo:imageViewObject repeats:NO];

I would suggest simply using performSelector:withObject:afterDelay:

[self performSelector:@selector(imageViewAnimation:) withObject:imageViewObject afterDelay:1.0];

Check out the NSTimer and NSObject references for more details.

Jacob Relkin
@Jacob Relkin, i also write same line in replacement of my in my question, but it still give me error(the app got _kill problem) of NSTimer.
RRB
@rajB, please give more detail.
Jacob Relkin
@Jacob Relkin, i updating my console back trace error.
RRB
A: 

in addition to Jacobs comment (and you want to still use NSTimer - one reason you might want to use NSTimer is you can cancel it):

imageAnimationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(imageViewAnimation:) userInfo:imageViewObject repeats:NO];

your method prototype also needs to be:

- (void) imageViewAnimation:(NSTimer*) timer

my guess is you have this wrong also...though without a stack trace & console output, just guessing.

Nick H247