• 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: Help with Basics (Was: help with bindings)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with Basics (Was: help with bindings)


  • Subject: Re: Help with Basics (Was: help with bindings)
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 20 Nov 2010 22:07:59 -0800

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@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

References: 
 >help with bindings (From: Rounak Jain <email@hidden>)

  • Prev by Date: Re: NSExpression is incorrect?
  • Next by Date: Re: Detecting shared folders
  • Previous by thread: help with bindings
  • Next by thread: define IBOUtlet connection in design time
  • Index(es):
    • Date
    • Thread