我想做网络服务的总结字段。
我有4个标签。它向我展示肥皂网服务的领域。我的3个标签可以,但我不知道我是如何收集总数的?
的Label1(AmountX)= 100,Label2的(AmountY)= 200,LABEL3(AmountZ)= 300,总(AmountX + AmountY + AmountZ) =(必须是600)
didStart
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:
(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary
*)attributeDict{
if ( [elementName isEqualToString:@"AmountX"] ) {
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
recordResults = YES;
}
if ( [elementName isEqualToString:@"AmountY"] ) {
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
recordResults = YES;
}
if ( [elementName isEqualToString:@"AmountZ"] ) {
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
recordResults = YES;
}
if ( [elementName isEqualToString:@"Total"] ) {
if (!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
recordResults = YES;
}
didEnd
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:
(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ( [elementName isEqualToString:@"AmountX"] ) {
Label1.text = soapResults ;
soapResults = nil;
recordResults = NO;
}
if ( [elementName isEqualToString:@"AmountY"] ) {
Label2.text = soapResults ;
soapResults = nil;
recordResults = NO;
}
if ( [elementName isEqualToString:@"AmountZ"] ) {
Label3.text = soapResults ;
soapResults = nil;
recordResults = NO;
}
// For Total ???
if ( [elementName isEqualToString:@"Total"] ) {
Total.text = soapResults ;
soapResults = nil;
recordResults = NO;
}