On 2010 Nov 20, at 20:00, Rounak Jain wrote:

> Please tell me the binding connections … I tried using NSArrayController but 
> could not get it right. Please guide me. 

Rounak, there are too many things wrong in your code.  The guidance I offer is 
that you need to set your project aside, study some of the basic Cocoa 
tutorials and documentation, and then after some days or weeks, depending on 
your prior experience, you will be ready to start using bindings.

> (Also, is there a way to reduce the four theCountries setValue: statements to 
> one?)

Since you asked, we'll start there.  Yes.  Use -[NSMutableDictionary 
dictionaryWithObjectsAndKeys:].

Next, it looks rather strange to be making all these collections mutable.  Now, 
it may be correct in your case, but it looks very weird, and more likely is the 
common beginner's mistake of making everything mutable.  Yes, it's convenient 
to be able to mutate away whenever you feel like it.  But it will lead to bugs 
when you start mutating the same object in different methods without copying it.

Another weird thing is your using alloc] init] instead of the so-called 
"convenience constructors".  Unless you're using garbage collection, these are 
memory leaks, and even if you are using garbage collection (which I never 
have), I think it's more conventional to use the convenience constructors.

Finally, in these last two lines

> myKeys = [[NSArray alloc]init];
> myKeys = [theCountries allKeys];

The first line has no effect (other than to leak memory if you're not using 
garbage collection).  The object that you've alloc] init]ed is a different 
object than the one returned by -allKeys.

Study some of the basics so that you know all of the terms I used in this 
message.  Post your improved code next week, and *then* someone could help you 
with bindings or whatever.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]
  • help with bindings Rounak Jain
    • Re: Help with Basics (Was: help with bindings) Jerry Krinock

Reply via email to