0
NSMutableArray *listOfItems;
Items *items = [ItemParser loadItemsForALevel:selectedLevel fromASuperLevel:selectedSuperLevel];
名單在我的for循環中,我加入一個NSMutableArray,以顯示給我的菜單層
for (Item *item in items.items) {
//Initialing a CCMenuItem and calling a removeMethod
CMenuItem *anItem = [[CCMenuItemSprite itemFromNormalSprite:[CCSprite spriteWithFile:item.picture]
selectedSprite:[CCSprite spriteWithFile:item.picture]
target:self
selector:@selector(removeMethod:)] retain];
NSString *textToDisplay;
textToDisplay = item.ItemText;
[listOfItems addObject:textToDisplay];
}
-(void)removeMethod:(id)sender {
CCMenuItemSprite *pointedItem = (CCMenuItemSprite *)sender;
//Now I'm removing only from the layer
[CCCallFunc actionWithTarget:pointedItem selector:@selector(removeFromParentAndCleanup:)]
//How do I remove it from array?
}
如何從listOfItems數組中刪除所選項並更新它?
謝謝!它崩潰並返回:'程序接收信號:EXC_BAD_ACCESS',有疑問? ;) – 2012-02-27 17:28:36
只需檢查textToDisplay是否返回一個字符串。 – Anish 2012-02-28 02:21:27