Do I have to format the value from date picker before storing in DB?
cheers
Depends on your needs. You can convert your date to a double precision floating point number very easily. That gives you very fast sorting, as well as fast calculation of the time span between dates. That gives you sub-millisecond accuracy. You could probably also cast the values to floats to make them smaller for storage, with a slight loss of accuracy.
NSDate has a method timeIntervalSinceReferenceDate that lets you convert dates to a double, and another method that lets you convert those values into dates.
If you just need month/day/year, you can build a date string and save that, using a date formatter, or write your own code using NSCalendar and NSDateComponents.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
now it throws an exception , and point to the last line .when I comment that line program works fine
Code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSPlaceholderDictionary initWithObjectsAndKeys:]:
second object of each pair must be non-nil. Or, did you forget to nil-terminate your parameter list?'
now it throws an exception , and point to the last line .when I comment that line program works fine
Code:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSPlaceholderDictionary initWithObjectsAndKeys:]:
second object of each pair must be non-nil. Or, did you forget to nil-terminate your parameter list?'
cheers
The NSDate method timeIntervalSince1970 returns a double, which is a scalar data type, not an object.
You can only add objects to dictionaries.
You need to convert your value to an NSNumber object if you want to save it in a dictionary:
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.