The Apple documentation says that the - (void)removeObject:(id)anObject method removes all occurrences of the given object from an NSMutableArray.
Is there a way to remove only one occurrence of the object from the array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have a particular instance that you want removed, which has a unique memory address but would otherwise compare equal to other instances, you would use
removeObjectIdenticalTo:.If you want to remove the first object in the array that fits the bill, use
indexOfObject:, which finds the lowest index, followed byremoveObjectAtIndex:You can also useindexesOfObjectsPassingTest:to get the list of all indexes that contain equal objects, as anNSIndexSet, and then pick one out from there — perhapslastIndex, e.g.