Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
Hi all,

I am trying a core-data sample application, from Cocoa Programming - Aaron Hillegass.

In it there is an entity Car, with following properties:

1. condition - Int 16
2. datePurchased - Date
3. makeModel - String
4. onSpecial - Boolean
5. photo - Binary
6. price - Decimal

There are certain view objects such as-

1. TableView
2. DatePicker
3. Image Well, etc.

Some of the bindings performed are-

1. TableView -> TableColumn with NSNumberFormatter (set as currency)-> value: arrangedObjects.price
2. DatePicker -> value: selection.datePurchased

Problems are:

1. In TableColumn with NSNumberFormatter it is not accepting any decimal numbers which I am entering for currency, such as - 123,00 or 123.45 or +235 or 567. It is always displaying this alert message: Formatting error.

2. Whenever I am selecting a row in table and changing its corresponding value in date picker, it is simultaneously changing the values for other records, ie. if for first row in table I have set it to 12/25/2004, it is keeping it 12/25/2004 for other rows.

Can anyone help me to resolve my problems? The source code can be found here

Thanks,

Monaj
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
Post code, how are we supposed to "guess" what is incorrect. All I can really say is "user error" at this point.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Post code, how are we supposed to "guess" what is incorrect. All I can really say is "user error" at this point.

He linked to the whole project zipped up. Not as obvious since the code isn't inline, but that's probably better than what we normally get.

-Lee
 

JoshDC

macrumors regular
Apr 8, 2009
115
0
1. It wants a currency symbol as well as a number. Ticking the lenient checkbox seems to fix this.

2. It's not changing the date, just that any new objects don't have a date to change to (and therefore the bound date picker doesn't change). You need to set the Car's class to an NSManagedObject subclass in the data model, create that subclass and override awakeFromInsert to set a default. This page gives you a bit of information on how to create a correct NSManagedObject subclass.
 

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
Hi JoshDC, thanx for your reply :)

Regarding:
1. It wants a currency symbol as well as a number. Ticking the lenient checkbox seems to fix this.

Can you tell me where can I find the lenient check box? I tried to search it in IB for NumberFormatter but was unable to find it.

Thanks,

Monaj
 

JoshDC

macrumors regular
Apr 8, 2009
115
0
Set the behaviour to Mac OS X 10.4+ Default, style to currency and there should be a Lenient checkbox next to the Localize one.
 

Monaj

macrumors regular
Original poster
May 24, 2009
193
0
Set the behaviour to Mac OS X 10.4+ Default, style to currency and there should be a Lenient checkbox next to the Localize one.

Hi JoshDC,

Once again thanks for your reply, but still unable to find lenient check box :(

I am posting the image of Inspector -> attributes property, so that you can help me to find it:

sUljTt2


Thanks,

Monaj

2. It's not changing the date, just that any new objects don't have a date to change to (and therefore the bound date picker doesn't change).

Your interpretation is correct, when I set the default value of datePurchased attribute to some value say- 2010-12-10 in MyDocument.xcdatamodel, it started working as intended :)

So I am now thinking that can we set default value to today's date in xcdatamodel ?

Thanks,

Monaj
 
Last edited by a moderator:

JoshDC

macrumors regular
Apr 8, 2009
115
0
Looks like you might be running an older version of Interface Builder to me. You can call setLenient: programatically (see NSNumberFormatter Class Reference).

You can't set today's date without going the subclassing route I explained before. It may seem a lot of effort, but it's worth learning for more complex Core Data applications!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.