• 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: Making a String from a non-NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making a String from a non-NSString


  • Subject: Re: Making a String from a non-NSString
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Tue, 27 Jan 2004 18:29:16 +0100

At 17:12 Uhr +0100 27.01.2004, Michael Becker wrote:
NSLog(@"%@", [ myTree childAtIndex: 0 ]); // This produces an output of the correct value "Archive Path"

%@ calls the "description" method of the object you pass it.

NSString* currentKey = (NSString*) [ myTree childAtIndex:0]);
NSLog(@"%@", currentKey); // This also produces an "Archive Path"

Same here, and you're just lucky because your type-casting an XMLTree to an NSString, but since both implement "description", NSLog() doesn't care.

if ([ currentKey isEqualToString:@"Archive Path"]) // THIS, however, produces a runtime error "[ XMLTree -isEqualToString:] selector not found"

Yes, because XMLTree != NSString.

Long story short: -childAtIndex: returns another XMLTree, but obviously it also holds the correct value (see the NSLogs above). Since there is no method in the class for explicitly returning the element value, is there ANY way I can get my comparison working?

Since "description" apparently returns the value, you could probably just use:

NSString* currentKey = [[myTree childAtIndex:0] description];
And then work with that?

Though it *does* seem kind of weird that XMLTree wouldn't have a method that returns its name, if its description returns such a name. Make sure you didn't just miss it before relying on description, because IIRC there are no guarantees as to the format of its value.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.
  • Follow-Ups:
    • Re: Making a String from a non-NSString
      • From: Michael Becker <email@hidden>
References: 
 >Making a String from a non-NSString (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: Any new/updated Cocoa books soon?
  • Next by Date: Re: [APP IDEA] Desktop Background Scripting
  • Previous by thread: Re: Making a String from a non-NSString
  • Next by thread: Re: Making a String from a non-NSString
  • Index(es):
    • Date
    • Thread