• 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: Shawn Erickson <email@hidden>
  • Date: Tue, 27 Jan 2004 08:53:28 -0800

On Jan 27, 2004, at 8:12 AM, Michael Becker wrote:

Hi!

This problem is a little hard to explain, so please bear with me :-)
I recently stumbled over the XMLTree-class by R.Harder (iharder.sourceforge.net), which is a simple objective-c wrapper for the CoreFoundation XML-functions. It works fine so far, but I run into problems when I want to compare elements. Here's the situation:

This is a part of my XML-file (yes, it's iPhoto's AlbumData.xml :-))

<key>Archive Path</key>
<string>/Users/johndoe/Pictures</key>

And here is the code-part (XMLTree is defined as a subclass of NSObject):

XMLTree* myTree;
[ . . . ]

NSLog(@"%@", [ myTree childAtIndex: 0 ]); // This produces an output of the correct value "Archive Path"

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

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


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?

Talk with R. Harder about it...? I doubt method don't exist to do what you want. I also wouldn't cast what you get back from childAtIndex to a NSString since it is obviously not always such an object, use id or something...

I can think of two things to try (not knowing the XMLTree class but based on info from the above only)...

[[currentKey description] isEqualToString:@"Archive Path"]

or

[@"Archive Path" isEqualToString:currentKey]

Anyway I am not sure you need to be using xml parsing classes for the above. The snippet sure looks like property list xml (http://developer.apple.com/documentation/Cocoa/Conceptual/ PropertyLists/index.html).

-Shawn
_______________________________________________
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: 
 >Making a String from a non-NSString (From: Michael Becker <email@hidden>)

  • Prev by Date: [JOB OPENING] Chronos L.C. Seeks Software Engineer (Cocoa)
  • Next by Date: Best way to implement calling another controller/class?
  • 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