xiaxiulong
xiaxiulong

Reputation: 41

How does performSelector:withObject:afterDelay: work?

I have found that after calling [self performSelector:@selector(method1:) withObject:self.tableView afterDelay:3]; that self.tableView's retainCount changes? Why?

Thank you very much!

Upvotes: 1

Views: 1016

Answers (2)

Nick Lockwood
Nick Lockwood

Reputation: 41005

You shouldn't have to worry about it - tableView will be retained while the selector is waiting to be executed and then automatically released again after it has executed. This won't cause leaks or crashes.

Upvotes: 1

eric.mitchell
eric.mitchell

Reputation: 8855

I believe the retain could of your table view would be incremented because calling performSelector: withObject: afterDelay: retains the parameter so that it isn't gone when the method finally is executed. Documentation here.

Upvotes: 2

Related Questions