私はObjective Cでのプログラミングは初めてで、実際にはプログラミングのようなものですらあります。私は少しシンプルな卓球ゲームを作っています.コンピュータープレーヤー用のAIを作ろうとしている間、プログラムは常に「シャットダウン」し、スレッド1でSIGABRTエラーが表示されます.
私はすでにこの質問をここでしましたが、実際には答えが得られませんでした.より多くのコードを提供するよう求められただけです.
エラーは実際にどこからともなく発生し、コードを編集していて突然表示され、最後に成功したビルド以降に記述されたコードを削除した後でもエラーが表示されます。私が知っているバックアップを開始したとしても。
だからここに私が持っているすべてのコードがあります。
PongViewController.m - エラーが表示される前に編集していたコード
#import "pongViewController.h"
#define kGameStateRunning 1
#define kGameStatePaused 2
#define kMicSpeedX 3
#define kMicSpeedY 4
#define ObtiznostPocitace 15
@implementation pongViewController
@synthesize mic,plosina_a,plosina_b,hrac_score,pocitac_score,gameState,micVelocity,TapToBegin;
- (void)viewDidLoad {
[super viewDidLoad];
self.gameState = kGameStatePaused;
micVelocity = CGPointMake(kMicSpeedX, kMicSpeedY);
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if(gameState == kGameStatePaused) {
TapToBegin.hidden = YES;
gameState = kGameStateRunning;
} else if (gameState == kGameStateRunning) {
[self touchesMoved:touches withEvent:event];
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
CGPoint xLocation = CGPointMake(location.x,plosina_a.center.y);
plosina_a.center = xLocation;
}
- (void) gameLoop {
if(gameState == kGameStateRunning) {
mic.center = CGPointMake(mic.center.x + micVelocity.x, mic.center.y + micVelocity.y);
if(mic.center.x > self.view.bounds.size.width || mic.center.x < 0) {
micVelocity.x = -micVelocity.x;
}
if(mic.center.y > self.view.bounds.size.height || mic.center.y < 0) {
micVelocity.y = -micVelocity.y;
}
} else {
if (TapToBegin.hidden) {
TapToBegin.hidden = NO;
}
}
//Collision Detection
if (CGRectIntersectsRect(mic.frame,plosina_a.frame)) {
if (mic.center.y < plosina_a.center.y) {
micVelocity.y = -micVelocity.y;
//NSLog(@"%f %f", mic.center,plosina_b.center);
}
}
if (CGRectIntersectsRect(mic.frame,plosina_b.frame)) {
if (mic.center.y > plosina_b.center.y) {
micVelocity.y = -micVelocity.y;
}
}
if(mic.center.y <= self.view.center.y) {
if(mic.center.x < plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x - ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
if(mic.center.x > plosina_b.center.x) {
CGPoint compLocation = CGPointMake(plosina_b.center.x + ObtiznostPocitace, plosina_b.center.y);
plosina_b.center = compLocation;
}
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
//jakovždy nakonec uvolníme co sme si obsadili
- (void)dealloc {
[super dealloc];
[mic release];
[plosina_a release];
[plosina_b release];
[hrac_score release];
[pocitac_score release];
[TapToBegin release];
}
@end
main.m - エラーが指しているコード
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
デバッガーが吐き出しているもの:
argc int 1
argv char ** 0xbffff6f4
*argv char * 0xbffff800
pool NSAutoreleasePool * 0x4b29340
NSObject NSObject {...}
_token void * 0x521a200
_reserved3 void * 0x0
_reserved2 void * 0x0
_reserved void * 0x0
retVal int -1073744132
そして、これは(デバッガーコンソールから)ですが、これは問題の一部ではないと思いますが、一体何を知っているのでしょうか。
This GDB was configured as "x86_64-apple-darwin".Attaching to process 11032.
Couldn't register com.yourcompany.pong with the bootstrap server. Error: unknown error code.
This generally means that another instance of this process was already running or is hung in the debugger.sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
助けてください。アプリケーションで発生したすべての警告を修正しようとしましたが、成功しましたが、まだ何もありません。