How to open multithreading

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.