Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Jun 21, 2009, 07:56 AM   #1
macrumors newbie
Join Date: Jun 2009
Location: East Tennessee
Core Data Date formatting issue

Hopefully someone can help me with this one. I have a contact management app that has date fields for "Last Contact date" and "Next Contact Date". I created a search predicate that would search on next contact date and display only the records for that date. It worked great until I decided I needed to create a user preference so the next contact date would automatically be some date in the futrure. I created a subclass of NSManaged object and put my code there.

Everything works except the date it writes to the database looks like this: >name="nextcontact" type="date">268045271.25241801142692565918<

For some reason my search predicate does not find the records with this format. Before I changed the date with my subclass the date field in the database looked like this: >266515200.00000000000000000000< (always containing the 00.00000000000000000000 string)
With this format the search predicate works fine.

My code to add to the date field looks like this:
- (void)awakeFromInsert {
int t;
t = [[NSUserDefaults stardardUserDefaults] integerForKey:@"nextContactDate"]; // gets # of days to add to date from user preferences
[self setValue:[NSDate dateWithTimeIntervalSinceNow: (3600*24*t)] forKey:@"nextContact"]; // sets the value of nextContact in a new record by adding 't'

The search predicate is quite simple and looks like this: nextContact = CAST($value "NSCalendarDate")

My question is how can I fomulate a date that will save as the second example above (or possibly change the predicate so it will work with the new date format).


Last edited by beaglboy; Jun 21, 2009 at 08:28 AM.
beaglboy is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Core Data Document-Based App Issues Blakeasd Mac Programming 0 Sep 13, 2011 09:09 PM
core data binding not working Javajax Mac Programming 3 Jul 10, 2011 01:23 PM
Reading Date from database in Ipad ashwinr87 iPhone/iPad Programming 0 Apr 25, 2011 11:11 AM
Help Needed - Xcode 4 Options: Use Core Data Include Unit Tests Mitch1984 iPhone/iPad Programming 3 Feb 26, 2011 03:42 PM
NSDatePicker Binding To A Core Data Date Attribute DVD Plaza Mac Programming 6 Jan 13, 2008 06:29 PM

All times are GMT -5. The time now is 05:07 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC