• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSComboBox Coredata bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComboBox Coredata bindings


  • Subject: Re: NSComboBox Coredata bindings
  • From: Wain <email@hidden>
  • Date: Wed, 30 Nov 2005 20:04:57 +0000


On 30 Nov 2005, at 18:13, Julien Bordet wrote:

Hi,

My Transaction Array Controller is in Entity mode, 'Automatically
prepares content' and is bound to ManagedObjectContext from my
PersistentDocument (MyDocument).

It is the same for my Category Array Controller.

The categories are programmatically added thanks to the following code :

---Start Code---

static char *CategoryDefaults[ maxCategoryDefaults ] =
{
	"Car", "House"
};

for (i = 0; i < 2; i++) {
NSString *typeString = [NSString stringWithCString:CategoryDefaults[i]];

NSManagedObject *type = [NSEntityDescription
insertNewObjectForEntityForName:@"Category"
inManagedObjectContext:managedObjectContext];

[type setValue:typeString forKey:@"category"];
}


---End Code---

Notice that it is never directly added to the Category controller.
That is another thing that I find weird...

Note that you said you set 'Automatically prepares content' earlier, basically that means that the
controller will keep an eye on your managed object context and update itself automatically.
So it sees the new categories as soon as you add them.



As I said, everything is OK except adding category through the interface. I try to fill the NSComboBox with, say, "Food", and validate with enter. Then I get the error message I mentioned in my first message.

From what you have said so far I think your data model looks like this:

< Transaction >
<    category    > <<------------> < Category >
					           <  category  >

where Transaction.category is a relationship
and Category.category is a string (the category name...)

Going back to what you said earlier:

That works fine for programmatically added category value : I can
select them through the NSComboBox. However, I cannot add a new
category through the user interface. When I enter it, I get a message

I'm surprised that you can select a category from the combo box as this will attempt
to set the string value of the Category's category attribute to the category relationship
of the Transaction, which expects a Category (NSManagedObject).
So, I'd expect a validation error whenever you try to do it.


(Which version of XCode are you using as I haven't seen that type of error before,
usually you get a validation error like:


Unacceptable type of value for to-one relationship:

rather than a failed method call...)

If your bindings for the combo box were:

content : CategoryArrayController.arrangedObjects

contentValues : CategoryArrayController.arrangedObjects.category

value : TransactionArrayController.selection.category.category
(note the additional .category)

Then you would be able to select the combo box entry as you are trying to set a string
to a string, but the value won't be stored as the Transaction still hasn't got a Category
to store.


The usual way to represent this to a user would be to have an NSPopupButton display
and allow selection of the Categorys.
This works differently as the combo box 'stores' and displays a list of strings where as the
popup button displays some string related to the list of OBJECTS it 'stores'.
You would then add Categories with an add: call to the controller and set the category
attribute via some other method.


If you really want to use the combo box I think your going to need to write some code to
intercept the action sent by the combo box and create a new Category yourself.


Whew, a little long winded, hope it helps (and I got your data model right!).

Wain


What other information do you need ?

Many thanks

Julien

2005/11/30, Wain <email@hidden>:
Hi,

Can you give a little more information about how your controller is
setup
and how you are adding the new category via the interface.

You bindings look reasonable (especially if it currently works if you
add
a category programmatically).

Wain


On 30 Nov 2005, at 15:46, Julien Bordet wrote:

Hi

I've search through the archives, and found some threads about this
subject, but nothing answering my question... If I'm wrong I'd be
happy to be redirected to interesting posts.

My main question is : how to use bindings and NsComboBox correctly.
More particularly, I want the application user to be apple to add item
through the interface.


I've created a NSArrayController that is responsible for a set of
NSManagedObjects.

One of the related entity property is a 'category' relationship.
Another CategoryArrayController is associated to that entity.

What I want to do is to manage Categories through a NSComboBox. I've
set bindings to :

content : CategoryArrayController.arrangedObjects

contentValues : CategoryArrayController.arrangedObjects.category

value : TransactionArrayController.selection.category

That works fine for programmatically added category value : I can
select them through the NSComboBox. However, I cannot add a new
category through the user interface. When I enter it, I get a message
:


2005-11-28 11:44:10.198 test[426] *** -[NSCFString? _isKindOfEntity:]
selector not recognized [self = 0x3f7b90]


Does anyone have a idea for that ?

Kind regards

Julien




___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40yahoo.co.uk


This email sent to email@hidden



___________________________________________________________ WIN ONE OF THREE YAHOO! VESPAS - Enter now! - http://uk.cars.yahoo.com/features/competitions/vespa.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >NSComboBox Coredata bindings (From: Julien Bordet <email@hidden>)
 >Re: NSComboBox Coredata bindings (From: Wain <email@hidden>)
 >Re: NSComboBox Coredata bindings (From: Julien Bordet <email@hidden>)

  • Prev by Date: more than one plist in a file.
  • Next by Date: Re: more than one plist in a file.
  • Previous by thread: Re: NSComboBox Coredata bindings
  • Next by thread: Finding the error...
  • Index(es):
    • Date
    • Thread