Jack Nutkins
Jack Nutkins

Reputation: 1555

Struggling to pass multiple parameters to performSelectorInBackground method

I found this piece of code from an earlier Stack Overflow question which describes how to pass multiple parameters to a performSelectorInBackground method.

However I'm struggling to apply the code to my problem, here is MY code:

- (void)callingMethod {
    NSDictionary * args = [NSDictionary dictionaryWithObjectsAndKeys:
                           cell, @"cell",
                           storyIndex, @"storyIndex",
                           nil];
    [self performSelectorInBackground:@selector(setCellImageWrapper:)
                           withObject:args];
}

- (void)setCellImageWrapper:(NSDictionary *)args {
    [self setCellImage:[[args objectForKey:@"cell"]]
             withIndex:[[args objectForKey:@"storyIndex"] intValue]];
}

- (void) setCellImage: (EventTableCell *)cell withIndex:(int)storyIndex {

    //My Code

}

As you can see I'm trying to pass an object of type EventTableCell to the setCellImage method from the setCellImageWrapper method. I'm getting the error "Expected Identifier" when I try to call the setCellImage -withIndex method. Can anyone tell me what I'm doing wrong?

Thanks,

Jack

Upvotes: 1

Views: 1140

Answers (1)

drewag
drewag

Reputation: 94733

If you remove the extra brackets around the

[args objectForKey:@"cell"]

it should compile fine

Upvotes: 5

Related Questions