我不敢确定我做错做什么。 我想到的是,国家宇宙航行局的名称和地段在不同的档案中申报。
#import <Foundation/Foundation.h>
@interface xmlToUrl : NSObject {
NSString *base_url;
NSMutableArray *field;
NSMutableArray *name;
}
@property(nonatomic,retain)NSString *base_url;
@property(nonatomic, retain)NSMutableArray *field;
@property(nonatomic, retain)NSMutableArray *name;
@end
以及
#import "xmlToUrl.h"
@implementation xmlToUrl
@synthesize base_url;
@synthesize field;
@synthesize name;
-(id) init
{
self = [super init];
if (self) {
field = [[NSMutableArray alloc] init];
name = [[NSMutableArray alloc] init];
}
return self;
}
-(void)dealloc
{
[base_url release];
[field release];
[name release];
[super dealloc];
}
@end
国家安全局 观察仪表层填充:
//nodeContent is just a NSMutableString being added to the *name 以及 *field NSMutableArrays
if([ending isEqualToString:@"name"]){
if(![nodeContent isEqualToString:@""])
{[xmlToUrlObject.name addObject:nodeContent];}
}
else if([ending isEqualToString:@"field"]){
if(![nodeContent isEqualToString:@""])
{[xmlToUrlObject.field addObject:nodeContent];}
Error = 预期. before . token. (关于以下法典第一行)
What I want for output: *url string contains base_url, urlPart2, 以及 urlPart3 all joined in order.
注
Base_url = @"www
url Part2 = @“mywebsite”
urlPart3 = @ .com
url = @“www.mywebsite.com”
//xmlToUrl is an instance of its own class (.m file) It contains the *name 以及 *field NSMutableArray
//xmlToUrl.h is inherited in this file
NSMutableString *urlPart2 = [xmlToUrl.name objectAtInd注 0];
[xmlToUrl.name removeObjectAtInd注0];
NSMutableString *url = [xmlToUrl.base_url stringByAppendingString:urlPart2];
if([xmlToUrl.field count] != 0)
{NSMutableString *urlPart3 = [xmlToUrl.field objectAtInd注 0];
[xmlToUrl.field removeObjectAtInd注0}
url = [url stringByAppendingString:urlPart3];
[urlPart2 release];
[urlPart3 release];