The application that developing is running fine on Xcode simulator, but when I am testing it on real device is terminated. Below is what my phone’s console prints out when app is terminated.
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
Basically, the problem occurs when I am firing a NSTimer (countdown) and reach ‘1’. Freeze for a while and then terminated.
Here is the method where timer initialised:
- (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);
}
Does anyone has a clue for this. Really … lost!
Thanks in advance
I am not sure if this is the source of the crash, but you do have a problem right here:
Basically, the fact that selector call has two
:means that it is expecting two arguments. If you use the methodperformSelector:withObject:afterDelay:, you can only use it with a method that has one argument.For example,
is equivalent to
and it will be performed after about 20 seconds.
In this case, you have a mismatch because your
@selectortakes two arguments, so you can not use it with that particularperformSelectormethod.While there is a
performSelector:withObject:withObjectmethod that takes two arguments, it does not have adelayargument. You might need to useNSInvocationinstead, or change theattackTo:attacker:so that it uses a single argument (for example, an NSDictionary).