0

私がやっている

        NSString *_type_ = @"report";
        NSNumber *_id_ = [NSNumber numberWithInt:report.reportId];

        NSDictionary *paramObj = [NSDictionary dictionaryWithObjectsAndKeys:
                                _id_, @"bla1", _type_, @"bla2",nil];

_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:) object:paramObj];

しかし、この行を処理した後でも、私の _operation オブジェクトは nil です。

ここでのセレクターは、実際に私が書いている関数で、次のようなものです。

-(void)initParsersetId:(NSInteger)_id_ type:(NSString *)_type_
{   
NSString *urlStr = [NSString stringWithFormat:@"apimediadetails?id=624&type=report"];
NSString *finalURLstr = [urlStr stringByAppendingString:URL];
NSURL *url = [[NSURL alloc] initWithString:finalURLstr];

NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

//Initialize the delegate.
DetailedViewObject *parser = [[DetailedViewObject alloc] initDetailedViewObject];

//Set delegate
[xmlParser setDelegate:parser];

//Start parsing the XML file.
BOOL success = [xmlParser parse];

if(success)
    NSLog(@"No Errors");
else
    NSLog(@"Error Error Error!!!"); 

}

誰か私が間違っているところを指摘してください。

事前にサンクス。

4

2 に答える 2

0

セレクターの名前はinitWithParserId:type:であるため、正しい行は


_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:type:) object:paramObj];
于 2010-06-11T13:10:49.907 に答える
0

@selectorメソッドのシグネチャと一致しないため、nil が返されます。また、便利なコンストラクターを使用して複数のパラメーターを渡すことはできません。パラメータを追加するには、を作成しNSInvocationて使用する必要があります。initWithInvocation:

http://theocacao.com/document.page/264

于 2010-06-11T13:14:42.390 に答える