• 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: Dereferencing a pointer in ObjC?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dereferencing a pointer in ObjC?


  • Subject: Re: Dereferencing a pointer in ObjC?
  • From: Marcel Weiher <email@hidden>
  • Date: Mon, 29 Jul 2002 09:42:25 +0200

On Monday, July 29, 2002, at 09:27 Uhr, Terry Simons wrote:

I have the following code:

if(@"Red" == [[myRadioMatrix selectedCell] title])

if ( [[[myRadioMatrix selectedCell] title] isEqual:@"Red"] )


Now... I can't do this because @"Red" is an NSString, but [[myRadioMatrix selectedCell] title] is an NSString *.

Not true. @"Red" evaluates to the pointer to the object. If you try this code, you will find that it type-checks OK. It still won't work because you're just comparing pointers, not the string contents.

Is this bad style?

If code that doesn't work is bad style: yes ;-)

Should I be using some NSString comparison method instead?

Yes.


--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Dereferencing a pointer in ObjC? (From: Terry Simons <email@hidden>)

  • Prev by Date: Re: espace disque nécessaire pour 10.2
  • Next by Date: application terminate, so what about memory...
  • Previous by thread: Dereferencing a pointer in ObjC?
  • Next by thread: Re: Dereferencing a pointer in ObjC?
  • Index(es):
    • Date
    • Thread