English 中文(简体)
应用NSMutableStrings - Exepected ...... ......
原标题:Appending NSMutableStrings - Exepected "." before "." token error

我不敢确定我做错做什么。 我想到的是,国家宇宙航行局的名称和地段在不同的档案中申报。

#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];
最佳回答

你们试图获得某类财产,而不是:

@interface xmlToUrl : NSObject { 

以及

NSMutableString *urlPart2 = [xmlToUrl.name objectAtIndex: 0];

只有在Xml的情况下,你才能获得财产。 与你一样,敦促:

{[xmlToUrlObject.name addObject:nodeContent];}

Here, xmlToUrlObject is an instance, 以及 not the class.

问题回答

暂无回答




相关问题
Subclass check, is operator or enum check

A couple of friends was discussing the use of inheritance and how to check if a subclass is of a specific type and we decided to post it here on Stack. The debate was about if you should implement a ...

C++ Class Inheritance problem

Hi I have two classes, one called Instruction, one called LDI which inherits from instruction class. class Instruction{ protected: string name; int value; public: Instruction(string ...

Overloading a method in a subclass in C++

Suppose I have some code like this: class Base { public: virtual int Foo(int) = 0; }; class Derived : public Base { public: int Foo(int); virtual double Foo(double) = 0; }; ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

Extending Flex FileReference class to contain another property

I want to extend the FileReference class of Flex to contain a custom property. I want to do this because AS3 doesn t let me pass arguments to functions through event listeners, which makes me feel sad,...

Interface Inheritance in C++

I have the following class structure: class InterfaceA { virtual void methodA =0; } class ClassA : public InterfaceA { void methodA(); } class InterfaceB : public InterfaceA { virtual ...

热门标签