I want to sort an array of NSDates only on their day month and year so not on any of the units of time. How can I do this because I can’t see a way of getting the individual parts of an NsDate “out”.
Share
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.
See this post for sorting an array containing NSDate objects:
Sort NSArray of date strings or objects
and mine for removing the time:
Truncate NSDate (Zero-out time)
ADDITION
1) Loop through your array of NSDate objects, removing (zeroing) the time components, and adding them to a new array:
2) Now that you have a new array consisting of NSDate objects with zeroed time components, you can sort them:
This line sorts the array using the NSDate object’s own comparator method.