Reference to pre-answered question at: Getting first and last days of current week
There are two answers in the above link. One of them is theoretical and the other is in a language called as PyObjC (Python-Objective C bridge language), and a quick google search confirms that PyObjC does not work with iPhone SDK.
So regarding the question, how is it possible to get the PyObjC code translated to be compatible with iPhone SDK.
Target: Supposing today (Tue.) is 19th, and Sun. was 17th (start of week) and Sat. 23rd is end of week. I want to get a string like 19/01 – 23/01 [i.e. The start of week (hypen) end of week]
If you have an
NSDate, you can use the currentNSCalendarto retrieve that date’sNSDateComponents. Set theNSDateComponents‘sweekdayto 1 (the first day of the week), create a copy, and set the copy’sweekdayto 7 (the last day of the week). Then use theNSCalendarto convert both theNSDateComponentsback to their respectiveNSDateobjects, after which you can use anNSDateFormatterto create your string representation.This link has an example about how to get a date’s weekday: https://stackoverflow.com/questions/1057349#1057405