2012-11-22 62 views
1

開發的應用程序在Xcode模擬器上運行良好,但是當我在真實設備上測試它時終止。以下是我的手機控制檯在應用程序終止時打印的內容。App在iPhone設備上意外終止,但在模擬器上正常工作

Nov 22 00:51:09 iPhone ReportCrash[3862] <Notice>: Formulating crash report for process CoL[3860] 
��Nov 22 00:51:09 iPhone ReportCrash[3862] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary 
��Nov 22 00:51:09 iPhone com.apple.launchd[1] (UIKitApplication:pan.ConquestOfLancaster[0xd857][3860]) <Warning>: (UIKitApplication:pan.ConquestOfLancaster[0xd857]) Job appears to have crashed: Segmentation fault: 11 
��Nov 22 00:51:09 iPhone backboardd[52] <Warning>: Application 'UIKitApplication:pan.ConquestOfLancaster[0xd857]' exited abnormally with signal 11: Segmentation fault: 11 
��Nov 22 00:51:09 iPhone ReportCrash[3862] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/CoL_2012-11-22-005109_iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0 
��Nov 22 00:51:09 iPhone awdd[3863] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary 

基本上,問題發生在我發射NSTimer(倒計數)並達到'1'時。凍結一段時間然後終止。

這裏是定時器初始化的方法:

- (void)MapMenu:(MapMenu *)menu didSelectButton:(NSInteger)index{ 

    if (index == 0) { 
     if (self.owner == nil && distance < 10) { 
      CountDownTimer* countDown = [[CountDownTimer alloc]init]; 
      [countDown startTimerOn:parentView]; 
      [self performSelector:@selector(attackTo:attacker:) withObject:nil afterDelay:20.0]; 
     } 
     else if (self.owner == @"Player_1") 
      NSLog(@"You have already occupy this building with name, %@", self.title); 
    } 
} 

- (void) attackTo: (BuildingViewController*) selectedBuilding attacker: (NSString*) attacker{ 

    self.owner = @"Player_1"; 
    NSLog(@"Building has a new owner with name, %@", self.owner); 
} 

有沒有人有這個線索。真的......迷路了!

在此先感謝

+0

既然它說,「制定崩潰報告」,也許這將有所幫助。 –

+0

對不起@PhillipMills,沒有明白你的意思。 :( – toto7

+0

正在創建一個崩潰報告,你應該看看它。使用Xcode組織者和檢查設備上的崩潰報告。 – Kerni

回答

2

我不知道這是否是崩潰的源頭,但你有一個問題就在這裏:

[self performSelector:@selector(attackTo:attacker:) withObject:nil afterDelay:20.0]; 

基本上,選擇呼叫有實際上是兩個:意味着它期待兩個參數。如果使用方法performSelector:withObject:afterDelay:,則只能將它與具有一個參數的方法一起使用。

例如,

[self performSelector:@selector(doSomething:) withObject:object afterDelay:20.0f] 

相當於

[self doSomething:object] 

,它將約20秒後進行。

在這種情況下,你有一個不匹配的,因爲你的@selector需要參數,所以你不能與特定的performSelector方法使用它。

儘管有一個帶有兩個參數的performSelector:withObject:withObject方法,但它沒有delay參數。您可能需要使用NSInvocation,或更改attackTo:attacker:,以便它使用單個參數(例如,NSDictionary)。

+0

你是一位老大:)謝謝!解決它! woohooo – toto7

0

我看到您使用一個名爲CountDownTimer的類。這是NSTimer的一個子類嗎?如果是這樣,您應該閱讀NSTimer類參考中的子類註釋。 NSTimer Class Reference

基本上,它說不這樣做。其實並非基本沒有,它說不這樣做。

當您閱讀類參考時,請查看如何在n秒後實現回調。就個人而言,我喜歡+ scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:

+0

你好@atreat。沒有我的CountDownTimer是UIView的子類。在那裏我只是調用一個方法20次爲了使用scheduledTimerWithTimeInterval方法更新屏幕上的定時器,我錯過了一個點? – toto7

+0

hmmm。按照你的類名,我假設不同。你看過你的文件/ var/mobile/Library/Logs/CrashReporter中的崩潰報告/CoL_2012-11-22-005109_iPhone.plist? – atreat

相關問題