I’m not going to write your code for you, but I’ll outline some things that will help:
The Cocoa date system consists of four major classes:
• NSDate represents an instant in time, without any sort of information about how a person would identify that instant. You can compare two NSDates to see which is earlier, or get the number of seconds between two dates, or calculate a date a certain number of seconds earlier or later. But an NSDate does not have a year, month, day, hour, minute, second, time zone, calendar system, or anything of the sort. It’s just an abstract moment in time, the way “now” or “twenty minutes from now” or “when the Berlin Wall fell" is the same time whether you’re using the Gregorian, Hebrew, Islamic, Japanese, or French revolutionary calendar.
• NSDateComponents represents a date and time as humans understand it: something with years, months, etc. You can manipulate all the individual fields, but you can do so in ways that aren’t really valid (like setting the seconds field to 90), and you can’t really compare two NSDateComponents.
• NSCalendar represents a calendar system. It can convert an NSDate into the corresponding NSDateComponents, or vice versa, bridging the gap between the two worlds. By passing a different calendar identifier when you create your NSCalendar, you can get a different system; NSCalendarIdentifierHebrew is the Hebrew calendar, and depending on what you’re trying to do, you might be interested in NSCalendarIdentifierGregorian as well.
• NSDateFormatter uses all of these classes together, plus NSLocale, to convert between NSDates and Strings. You can go in either direction, and use NSDateFormatter’s options to control almost everything about how the conversion is done, including changing the calendar system.
I’m not entirely clear on what you’re trying to do, but here are a few possibilities:
• If you’re trying to take the current date and output it as a string in the Hebrew calendar, you’ll get an NSDate representing the current moment with NSDate(), then configure an NSDateFormatter with a Hebrew NSCalendar and whatever other options you want, and convert your NSDate to a String.
• If you’re trying to take the current date and break it down into Int year/month/day/etc. so you can do something else with them, you’ll get the current date with NSDate(), then get a Hebrew NSCalendar and instruct it to convert that date to an NSDateComponents, specifying the fields you’re interested in. The resulting NSDateComponents object will contain all the information you need to do whatever it is you’re trying to do.
• If you’re converting between user-provided Gregorian dates and Hebrew dates, you’ll do one of the above in reverse to get an NSDate, then do it forward again to get the NSDateComponents in the other calendar system.