这只是一个想法,
您有一个包含所有对象的数组。您只需要知道要删除哪一个。那么,为什么不给每个tag
添加到数组中的对象 a 呢。当你去删除那个对象时,测试它的标签并删除它。
//Say your array has 10 objects in it,
//There will be 10 objects each with a tag 1-10.
//When you want to delete an object,
编辑
//Before you add each object to the array, use a `for` loop
for (int i = 0; i < theMaxNumberOfTagsYouWant; i++)
{
self.myObject.tag = i;
[self.myArray addObject:self.myObject];
//This will loop thru as many times as you want, specify using the
//maxNumberOfTagsYouWant variable. and it will give it a tag, which'll be the value of `i`
//which gets increased for each object you insert into the array, Then when you want to
//remove the object, use the below code to remove the object using it's tag.
}
-(void)deleteObjectFromArray{
[self.myArray removeObjectAtIndex:myObject.tag];
}
希望这个对你有帮助。:)