ios - How to call instance methods inside a block? -


i want call instance methods inside block. here method working with,

[self.somevariable addboundarytimeobserverfortimes:timearray queue:null usingblock:^{     [self myinstancemethod]; }]; 

but not able reference self inside block. should do?

edit: sorry posted question in hurry. getting warning (capturing 'self' in block lead retain cycle) approach.

using self directly inside block may cause retain cycle, avoid retain cycle should create weak reference self , use reference inside block call instance methods. use below code call instance methods inside block

__weak yourviewcontroller * weakself = self; [self.somevariable addboundarytimeobserverfortimes:timearray queue:null usingblock:^{     [weakself myinstancemethod]; }]; 

Comments