• 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: A bit stumped....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A bit stumped....


  • Subject: Re: A bit stumped....
  • From: "David P. Henderson" <email@hidden>
  • Date: Fri, 20 Jul 2001 11:09:37 -0400

On Friday, July 20, 2001, at 10:49 , email@hidden wrote:

> if ( rwdString == readString )
> NSLog (@"It's equal to Read");
> else if ( rwdString == writeString )
> NSLog (@"It's equal to Write");
> else if ( rwdString == deleteString )
> NSLog (@"It's equal to Delete");
> else
> NSLog (@"It's not equal to any of those, it's \"%@\"",
> rwdString);
>
> It ALWAYS tells me it's not equal to any of the strings, though with
> the last NSLog entry, I see either Read, Write, or Delete. What
> gives? Is the titleOfSelectedItem in some other encoding than the
> other strings? Or will this just not work (I hope that's not the
> answer, it would make things difficult!)?
>
You are testing pointer equality not string equality. [rwdString
isEqualToString:readString] will test string equality. But a better way
to test which menu item you're getting is to set the tag of each item in
IB and test for the tag, ([rwdTag tag] == 0) or if each item in the menu
performs a different action test for the action, [rwd action] ==
@selector(readAction:). This way you insure that you can easily localize
your application without breaking it or needing to rewrite your
conditionals later.

Dave
--
Chaos Assembly Werks
"Nothing is too good to be true, except, perhaps, the morality of a
bishop."
- Israel Zangwill


References: 
 >A bit stumped.... (From: email@hidden)

  • Prev by Date: Re: A bit stumped....
  • Next by Date: Re: A bit stumped....
  • Previous by thread: A bit stumped....
  • Next by thread: Re: A bit stumped....
  • Index(es):
    • Date
    • Thread