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 回答