ios - How to call performSelectorInBackground with a function having arguments? -


sorry newbie question (maybe). i'm developing app ios , i'm trying execute external xml reading out of main thread in order not freeze ui while call doing magic.

this way know made process not execute in main thread in objective c

[self performselectorinbackground:@selector(callxml)                            withobject:self]; 

so did incapsulate call function

 - (void)callxml{      [rxmlelement elementfromurl:[nsurl urlwithstring:indxml]];  } 

now have make string indxml parameter of function in order call different xml need to. like

 - (void)callxml:(nsstring *) name{      [rxmlelement elementfromurl:[nsurl urlwithstring:indxml]];  } 

in case, how call performselector change? if in usual way syntax errors:

[self performselectorinbackground:@selector(callxml:@"test")                            withobject:self]; 

[self performselectorinbackground:@selector(callxml:)                        withobject:@"test"]; 

ie: pass in withobject: becomes parameter method.

just point of interest here's how using gcd:

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{     [self callxml:@"test"];      // if need execute making sure it's on main thread (updating ui example)     dispatch_async(dispatch_get_main_queue(), ^{         [self updategui];     }); }); 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -