Reputation: 95
i have a class MatchDayDataController , having a method pushIncompleteDataToServer.
from another class , SummaryVC.m i want to call pushIncompleteDataToServer in performSelectorInBackground.
Code:
MatchDayDataController *sharedDataController = [MatchDayDataController sharedDataController];
[self performSelectorInBackground:@selector([sharedDataController pushIncompleteDataToServer]) withObject:nil];
It shows some syntax error in performSelectorInBackground. What i missed here? pls guide.
Upvotes: 0
Views: 157
Reputation: 69
[self performSelectorInBackground:@selector([sharedDataController pushIncompleteDataToServer]) withObject:nil];
This would make the code to search for the method in the same class
It should be:
[sharedDataController performSelectorInBackground:@selector(pushIncompleteDataToServer) withObject:nil];
which would call the method in the sharedDataController
class
Also, in the method performSelectorInBackground: withObject:
the withObject is for the parameters to be passed to the selector method. I this case, since there are no parameters, we pass nil.
Upvotes: 3
Reputation: 8180
You need to replace self
with sharedDataController
.
[sharedDataController performSelectorInBackground:@selector(pushIncompleteDataToServer) withObject:nil];
The selector will be performed on the receiver of the performSelectorInBackground
message, and self
doesn't implement that method.
Upvotes: 0
Reputation: 5182
Try this,
[sharedDataController performSelectorInBackground:@selector(pushIncompleteDataToServer) withObject:nil];
instead of
[self performSelectorInBackground:@selector([sharedDataController pushIncompleteDataToServer]) withObject:nil];
Upvotes: 0