我剛剛削減了大量的錯誤,現在我的代碼編譯得很好,但它總是在我創建的createEntity方法中崩潰。看起來沒有什麼問題,但有人可以幫我嗎?有什麼建議嗎?在看起來沒有錯誤的地方崩潰
-(void)createEntityWithX:(int)newEntityX andY:(int)newEntityY withType:(int)newEntityType withWidth:(int)newEntityWidth andLength:(int)newEntityLength atSpeed:(int)newEntitySpeed
{
Entity tmpEntity;
tmpEntity.entityX = newEntityX;
tmpEntity.entityY = newEntityY;
tmpEntity.entityLength = newEntityLength;
tmpEntity.entityWidth = newEntityWidth;
tmpEntity.entityType = newEntityType;
tmpEntity.entitySpeed = newEntitySpeed;
int arrayAmount = [entityArray count];
NSValue *tmp = [NSValue valueWithBytes:&tmpEntity objCType:@encode(struct Entity)];
[entityArray insertObject:tmp atIndex:arrayAmount];
[tmp release];
}
你有沒有調試過,看看哪一行是造成麻煩? – Anila
int arrayAmount = [entityArray count]; NSValue * tmp = [NSValue valueWithBytes:&tmpEntity objCType:@encode(struct Entity)]; [entityArray insertObject:tmp atIndex:arrayAmount];其中一個......編譯好但崩潰時,這種方法被稱爲 – DuskFall
和什麼是崩潰消息? – Anila