read


<h3>First way (NSOperationQueue):</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;"> NSOperationQueue *q = [[NSOperationQueue alloc] init];
[q addOperationWithBlock:^{
//Do Things
}];
[q release];
</pre><h3>Second way:</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;"> [self performSelectorInBackground:@selector(func1:) withObject:nil]; </pre>
<h3>Third way (Schedule with timer):</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;"> [NSTimer scheduledTimerWithTimeInterval:1.0 target:self
selector:@selector( methodName: )
userInfo:parameter repeats:NO];
</pre>
Source

<h3>Notes</h3>If you want to run code in the main thread from other thread (like GUI updates or another…) see
Run code in main thread from other

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview