iOS single-case design mode

Source: Internet
Author: User

The singleton pattern means that there is only one instance. The singleton pattern ensures that a class has only one instance, and instantiates itself and provides this instance to the system as a whole. This class is called a singleton class.
The singleton availability is very high and is available for global invocation, such as login user management.

    1. + (Accountmanager *) Sharedmanager
    2. {
    3. static Accountmanager *sharedaccountmanagerinstance = nil;
    4. static dispatch_once_t predicate;
    5. Dispatch_once (&predicate, ^{
    6. Sharedaccountmanagerinstance = [[Self alloc] init];
    7. });
    8. return sharedaccountmanagerinstance;
    9. }

iOS single-case design mode

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.