开发者

NSInvocation object not getting allocated iphone sdk

I'm doing

        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];

But my _operation object is nil even after processing this line.

The selector here is actually a function I'm writing which is like:

-(void)initParsersetId:(NSInteger)_id_ type:(NSString *)_type_
{   
NSString *urlStr = [NSString stringWithFormat:@"apimediadetails?id=624&开发者_C百科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!!!"); 

}

Can anybody please point out wheather where I'm going wrong.

Thanx in advance.


Your @selector doesn't match your method signature, which is why it's returning nil. Also, you can't use the convenience constructor to pass multiple parameters. You'll have to create an NSInvocation and use initWithInvocation:to add the parameters.

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


The name of your selector is initWithParserId:type:, so the correct line is


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜