I am making a request using AFNetworking to an endpoint which returns XML Response. The response always returns a 200 status code even if it is logically failed. In this case the response body either returns 0 if failed or 1 if successful.
I am using [AFXMLParserResponseSerializer serializer] to serialize the response which returns an NSXMLParser object as response in the success block of the request.
I need to parse this NSXMLParser object and convert it to NSString so that I can check whether the request failed or succeeded.
I tried parsing the response like this
In the success block
NSXMLParser *xmlResponse = response;
xmlResponse.delegate = self;
[xmlResponse parse];
Then in the delegate
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([string isEqualToString:@"0"]) {
// Whatever stuff I want to do
}
}
But I think this is not the correct way. Am I doing it wrong?