views:

49

answers:

2

Hi all,

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&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.

A: 

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


_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:type:) object:paramObj];
asandroq
No, it's still not getting allocated..:(
neha
A: 

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

kubi
I have gone through the link you provided, but in initWithTarget:selector:object: ,can't I pass arguments in an nsdictionary object directly? I've to do this process for as many as 10 different nsinvocationobjects and the approach by Scott Stevenson [which is awesome], will I think introduce redundancy in my case. Also it's not getting allocated after changing the method signature.
neha
You can't pass arguments in an `NSDictionary`. `NSInvocation` objects are mutable, so you can just edit the same object for each of your 10 different method calls.
kubi