Re: Core Data question
Re: Core Data question
- Subject: Re: Core Data question
- From: Quincey Morris <email@hidden>
- Date: Wed, 6 Aug 2008 18:01:23 -0700
On Aug 6, 2008, at 12:31, Sandro Noel wrote:
Now, when I try to set the value for the [date] or [Amount] or
[TransactionType], of the ManagedObject, i get an error:
*** -[NSCFString managedObjectContext]: unrecognized selector sent
to instance 0xXXXXXeXX
The only thing that really works fine are the strings, I don't get
it... must be a simple mistake from my part here.
or something I missed in the documentation...:S
The error says you are sending a 'managedObjectContext' message to a
string (instead of to a NSManagedObject). Set a breakpoint at
objc_exception_throw and you should see in the stack trace where this
is happening, and then work out what to do about it. You may actually
be sending the message to the wrong object, or you might have a memory
management error.
another thing I would like to understand, do relationships work like
constraints in SQL ?
in the sense that if there is no transactionType defined in the
TransactionTypes Entity,
I would not be able to insert a value in the transactionType field
of the transactions entity?
If you don't have a TransactionTypes object for a Transactions object,
you can leave the TransactionType relationship unset (i.e. nil). If
the Transactions entity says it's optional, you can leave it that way
forever and there's no problem. If it's not optional, there's no
immediate error, but you'll get a validation error when you try to
save the persistent store.
do I have to first select/fetch an object from the transactionsType
entety, and assign that to the transactionType atribute of the
transactions entety...?
If you're starting from a transaction type name as you show in your
sample code, you'll have to do a fetch to find the object with that
name (every time you need it, or do it once during startup and create,
say, a dictionary that ties the names to the objects in a more
convenient way).
This line:
[transaction setValue:tr.transactionType
forKey:@"TransactionType.Name"];
isn't going to work. You've given it a key path, so you would need to
use [setValue:forKeyPath:] instead of [setValue:forKey:]. But in any
case it's the wrong key path. This isn't going to fetch the correct
transaction type, it's going to change the name of the transaction
type, which is not what I think you want to do.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden