Methods for creating threads
Nsthread
Nsoperationqueue and Nsoperation
GCD
Executing code in the main thread
[Self performSelectorOnMainThread:withObject:waitUntilDone:];
[Self performselector:onthread:[nsthread mainthread] Withobject:waituntildone:];
Dispatch_async (Dispatch_get_main_queue (), ^{
});
Delay execution
Double delayinseconds = 2.0;
dispatch_time_t poptime = Dispatch_time (Dispatch_time_now,
(int64_t) (Delayinseconds * nsec_per_sec));
Dispatch_after (Poptime, Dispatch_get_main_queue (), ^ (void) {
});
[Self performSelector:withObject:afterDelay:];
[Nstimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:];
Loadview
When using the controller's view for the first time, the Loadview method is called to create the view
In general, customize the view here
When the controller view is used for the first time, it is called
Viewdidload
Called when the controller's view is created, that is, after Loadview
It is common to add child controls, initialize data
Viewdidunload
Called when the controller's view is destroyed because of a memory warning
Usually here to recycle the interface-related resources (the interface will be destroyed, and interface-related resources must not be)
How to open multithreading