I want to move a string item to the top of the list.
NSMutableArray animal = "cat", "lion", "dog", "tiger";
How do I move dog to top of the list?
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.
You would remove the item and insert it at the correct space:
You have to retain the object or when you tell the array to remove it, it will release the object.
If you don’t know the index you could do something like this:
This method will go over all your list and search for “dog” and if it finds it will remove it from the original list and move it to index 0.