English 中文(简体)
单人坠毁器
原标题:iPhone: invalidate NSTimer from app delegate crashes app

我正试图从我的代表那里操作一种方法,该方法节省了其他类别中的物体,也使一名时间失效。 我已设立这一机制,这样,在我准备离开时,它就采用我的班子的方法,节省时间,停止时间。

代表:

- (void)applicationWillResignActive:(UIApplication *)application {

    // Save the mission because they are leaving the app
    if ([timeRun hasScore]) {
        [timeRun resetWithSave];
    }

}

它在“时值”类中所用的方法:

- (void)resetWithSave {
    // Save
    self.counterInt = 150;
    self.timer.text = [self timeInSeconds:counterInt];
    [start setBackgroundImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
    self.started = NO;
    self.score.text = @"0";
    [self saveMission];
    if ([countTimer isValid]) {
        [countTimer invalidate];
    }
    [table scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];
}

但我正在坠毁:

2010-09-11 19:35:21.503 Score Card[2747:307] -[__NSCFType isValid]: unrecognized selector sent to instance 0x19e190
2010-09-11 19:35:21.594 Score Card[2747:307] *** Terminating app due to uncaught exception  NSInvalidArgumentException , reason:  -[__NSCFType isValid]: unrecognized selector sent to instance 0x19e190 
*** Call stack at first throw:
(
    0   CoreFoundation                      0x30897ed3 __exceptionPreprocess + 114
    1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
    2   CoreFoundation                      0x30899683 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
    3   CoreFoundation                      0x308411d9 ___forwarding___ + 508
    4   CoreFoundation                      0x30840f90 _CF_forwarding_prep_0 + 48
    5   Score Card                          0x00006b3d -[TimeRun resetWithSave] + 272
    6   Score Card                          0x00002b39 -[Score_CardAppDelegate applicationWillResignActive:] + 80
    7   UIKit                               0x31ea6879 -[UIApplication _setActivated:] + 212
    8   UIKit                               0x31eda4ab -[UIApplication _handleApplicationSuspend:eventInfo:] + 238
    9   UIKit                               0x31eab301 -[UIApplication handleEvent:withNewEvent:] + 2200
    10  UIKit                               0x31eaa901 -[UIApplication sendEvent:] + 44
    11  UIKit                               0x31eaa337 _UIApplicationHandleEvent + 5110
    12  GraphicsServices                    0x31e4504b PurpleEventCallback + 666
    13  CoreFoundation                      0x3082cce3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
    14  CoreFoundation                      0x3082cca7 __CFRunLoopDoSource1 + 166
    15  CoreFoundation                      0x3081f56d __CFRunLoopRun + 520
    16  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
    17  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
    18  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
    19  GraphicsServices                    0x31e4469f GSEventRun + 62
    20  UIKit                               0x31e51123 -[UIApplication _run] + 402
    21  UIKit                               0x31e4f12f UIApplicationMain + 670
    22  Score Card                          0x000029ef main + 70
    23  Score Card                          0x000029a4 start + 40
)
terminate called after throwing an instance of  NSException 
Program received signal:  “SIGABRT”.
kill
quit

为什么会错失我的想法?

问题回答

在座椅上,你再次做像样的事情。

countTimer = [NSTimer scheduledTimerWithTarget:...];

...

if ([countTimer isValid])
{
  [countTimer invalidate];
}

...


if ([countTimer isValid])
{
  [countTimer invalidate];
}

在你们的跑道上添加了“预定”的时间。 然后,它保留下来。 伪造文件将它从跑道上清除,因此释放。 如果没有其他东西保留,它就被处理。 当你试图再次使用时,它便坠毁。

诸如<代码>[现时失效];计时=无;

或者,你可以保留时间,但指出时间选择保留目标,以便随着保留周期而轻松结束。

它认为,从来就没有开始时间,或被释放。 有时,在无照的情况下,会以随机物体提出例外。 检查你的点子并保留计数!





相关问题
Ruby Interpreter crashes with a certain word

Ok, this one s a little ridiculous, and I m almost afraid no one will believe me. But here it goes: I have written a Ruby Rails application that handles content for tons of domains. Now I know this ...

Java HotSpot error

Curious if anyone could help out in regards to a Java HotSpot dump...saw some reference to head over to the Sun Forums, figured I would try here first...below is the dump... # # An unexpected error ...

NSOperation performSelectorOnMainThread crashes

I m calling a NSOperation from a Subview of a NavigationController. MyOperation *op = [[MyOperation alloc] target:self action:@selector(didFinishOperation)]; The Operation loads some data from a ...

Is this kind of crash report useless?

I tried use "PLCrashReport" to collect the crash info then make the app more stable, but turns out that the report is like this(dont even has a call stack,how am I suppose to use it?): The "Exception:...

Xcode crashes with divide by zero

I downloaded urlcache.zip from http://developer.apple.com/iphone/library/samplecode/URLCache/index.html#//apple_ref/doc/uid/DTS40008061 I opened the project in xcode and clicked on urlcacheconection....

热门标签