何が間違っているのかわかりません。NSMutableArrayの*nameと*fieldが別のファイルで宣言されているためだと思います。
#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
NSMutableArraysはViewControllerクラスに入力されます。
//nodeContent is just a NSMutableString being added to the *name and *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];}
エラー=予期される'。' 前 '。' トークン。(以下のコードの最初の行)
出力したいもの:* url文字列には、base_url、urlPart2、およびurlPart3がすべて順番に結合されています。
元:
base_url =@"www。"
urlPart2 = @ "mywebsite"
urlPart3 =@"。com"
url = @ "www.mywebsite.com"
//xmlToUrl is an instance of its own class (.m file) It contains the *name and *field NSMutableArray
//xmlToUrl.h is inherited in this file
NSMutableString *urlPart2 = [xmlToUrl.name objectAtIndex: 0];
[xmlToUrl.name removeObjectAtIndex:0];
NSMutableString *url = [xmlToUrl.base_url stringByAppendingString:urlPart2];
if([xmlToUrl.field count] != 0)
{NSMutableString *urlPart3 = [xmlToUrl.field objectAtIndex: 0];
[xmlToUrl.field removeObjectAtIndex:0}
url = [url stringByAppendingString:urlPart3];
[urlPart2 release];
[urlPart3 release];