Reputation: 96
Firstly, as I see many others seem to announce when they ask these types of questions, I'm a beginner to Objective C. I've come from a strong PHP background, so I do understand most programming concepts, and have been learning Obj C on and off for the past 12 months.
One of my first projects to get my feet wet with iOS Objective C was to integrate with the Magento SOAP API. Probably not the easiest thing to begin with, but nonetheless it's a good challenge.
I'm currently trying to integrate XMLReader (https://github.com/amarcadet/XMLReader). But XCode keeps throwing me an error: ARC Semantic Issue: No known class method for selector 'dictionaryForNSXMLParser:'
Which refers to the following code:
NSDictionary *dict = [XMLReader dictionaryForNSXMLParser:parser];
I found some advice from another question: How can you use AFNetworking or STHTTPRequest to make a request of a SOAP web service?
I've reverted my code to mirror exactly the examples provided in the question, so I've been wracking my brain to work this error out, but to no avail.
Any help is much appreciated, and I apologise if this is something stupid which I have overlooked. I've tried scouring google for similar issues, but they all seem to be leading to class methods being called on an instance, etc.
Upvotes: 0
Views: 694
Reputation: 757
I was trying that code myself just a minute ago.
You have to add in XMLReader.h
:
+(NSDictionary*)dictionaryForNSXMLParser:(NSXMLParser*)parser error:(NSError **)error;
Then in the XMLReader.m
these two:
+ (NSDictionary *)dictionaryForNSXMLParser:(NSXMLParser *)xmlParser error:(NSError **)error
{
XMLReader *reader = [[XMLReader alloc] initWithError:error];
NSDictionary *rootDictionary = [reader objectWithNSXMLParser:xmlParser options:0];
return rootDictionary;
}
- (NSDictionary *)objectWithNSXMLParser:(NSXMLParser *)xmlParser options:(XMLReaderOptions)options
{
// Clear out any old data
self.dictionaryStack = [[NSMutableArray alloc] init];
self.textInProgress = [[NSMutableString alloc] init];
// Initialize the stack with a fresh dictionary
[self.dictionaryStack addObject:[NSMutableDictionary dictionary]];
[xmlParser setShouldProcessNamespaces:(options & XMLReaderOptionsProcessNamespaces)];
[xmlParser setShouldReportNamespacePrefixes:(options & XMLReaderOptionsReportNamespacePrefixes)];
[xmlParser setShouldResolveExternalEntities:(options & XMLReaderOptionsResolveExternalEntities)];
xmlParser.delegate = self;
BOOL success = [xmlParser parse];
// Return the stack's root dictionary on success
if (success)
{
NSDictionary *resultDict = [self.dictionaryStack objectAtIndex:0];
return resultDict;
}
return nil;
}
After that remember to import XMLReader.h and use the method. Notice that it has the error handling in it so if you copy pasted the code it's not same.
[XMLReader dictionaryForNSXMLParser:parser error:nil];
If it still doesn't work try cleaning the project with CMD
+SHIFT
+K
and building it again.
Upvotes: 1