Basically I want to know I a user chooses from my settings what day they want a week to start on (This would have a value in the format, @”Mon” for example) and I have an NSMutableArray that holds NSDates (users add theses dates throughout the life of the app) ordered in a chronologically ascending manner, but not necessarily consecutive (there could be day’s that users missed and did not add the date to the array), how could I determine that a particular NSDate in the array is part of a different week (relative to the date the user chose for a week to start on)?
Share
This will give you the difference between two dates in weeks:
So
if(!weekDiff){ /*same week*/}Complete example:
For converting strings to NSDates, see NSDateFormatter
edit as response to comment
if you want to have a week that starts with the first date you pass in, you could instead count the days and check if they have more than 7 days difference.