Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vilelam

macrumors newbie
Original poster
Feb 20, 2011
3
0
Hi Experts,
I'm trying to figure out whats wrong with this code, it returns an error while its running. I'm trying to implement a parser using NSXMLParser class.
The error is: "[ParseXML setCurrentProperty:]: unrecognized selector sent to instance 0x100112e70" and it happens into the delegate method bellow:

Code:
- (void) parser : (NSXMLParser *)parser didStartElement : (NSString *)elementName 
         namespaceURI : (NSString *)namespaceURI qualifiedName : (NSString *)qName 
         attributes : (NSDictionary *)attributeDict {

    if ( [elementName isEqualToString:@"lastName"] ) {
        
        [COLOR="DarkRed"][self setCurrentProperty:kABLastNameProperty];[/COLOR]
        return;
    
    }
}



I'm importing AddressBook framework but it seems that the method setCurrentProperty is no available into my class. Any help will be appreciated.

Thanks,
Marcos Vilela.
 
Last edited by a moderator:
Dejo and Jnoxx,
thanks for the answers.

I didn't create any method called setCurrentProperty, but I'm importing Address Book Framework into my class.


To implement this code, I`m following a guide from Apple (Event-driven XML programming guide) and from the guide I got this information:

[self setCurrentProperty:kABLastNameProperty] -> Sets an instance variable holding the current Address Book property; this value is a enum constant declared in the Address Book framework.

Is it enought to #import address book framework? In my opinion, it seems that my class need to extend another class with this method (setCurrentProperty).


Any help?


Thanks,
Marcos Vilela.
 
Is it enought to #import address book framework?
Almost certainly not. Can you tell us more about what you're trying to achieve? You're parsing an XML document, that much we know. But then what are you doing with the data from that XML? What is the object whose current property you are hoping to update? Think about these things some more and perhaps the issues with your code will become clearer.

Also, what is your comfort level with Objective-C / iPhone programming? What have you done to educate yourself on the basic fundamentals? And please: be specific. "I read a book" or "I took some online tutorials" are too vague.
 
Hi Dejo,
I Solved the problem implementing the setCurrentProperty method as you told in the first reply. Very easy...

@property (nonatomic, copy) NSString *currentProperty;
@synthesize currentProperty;

Aswering your question, I'm new to objective C and trying to learn the syntax coding this XMLParser. I've never read a book... just did a hello world before this parser.. lol..

Thanks and regards,
Marcos Vilela.
 
Aswering your question, I'm new to objective C and trying to learn the syntax coding this XMLParser. I've never read a book... just did a hello world before this parser.. lol..
Then I would suggest you step away from the real coding and go learn the basics of Objective-C / iPhone programming. It will help if you learn to walk before you run. Probably wouldn't hurt to check out the Guides and Stickies at the top of this very forum either.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.