Prefix for iOS attributes or variables-Miscellaneous

Source: Internet
Author: User

The function of the static keyword:

(1) The function body static variable scope is the function body, different from the auto variable, the memory of the variable is only assigned once,

Therefore, its value remains the last value at the next call;

(2) The static global variable within the module can be accessed by functions used within the module, but not by other functions outside the module;

(3) The static function within the module can only be called by other functions within this module, and the use of this function is limited to the Declaration

within its module;

(4) A static member variable in a class is owned by the entire class and has only one copy of all objects of the class;

(5) The static member function in a class is owned by the entire class, which does not receive the This pointer, and therefore can only access static member variables of the class .


What are the differences and connections between threads and processes ?

Processes and threads are the basic units that the operating system realizes, and the system uses this basic unit to realize the concurrency of the system to the application.

The main difference between threads and processes is that they are different ways to manage operating system resources. The process has a separate address space, and after a process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process. Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equal to the entire process dead, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, efficiency is worse. But for some concurrent operations that require simultaneous and shared variables, only threads can be used, and processes cannot be used.

What is the class factory method?

The class factory method is implemented to provide convenience to the customer, who will assign and initialize the compound in one step, return the object being created, and

For automatic release processing. The form of these methods is + (type) className ... (where classname does not include any prefixes).

Factory methods may not be easy to use. Not only can they combine allocations and initial, but they can also provide the initialization process with

The distribution information of the image.

Another purpose of the class factory method is to make a single instance of a class (such as Nsworkspace). Although Init ... method to confirm a

Class has only one instance per program run, but it needs to assign a "live" instance first, and then must also dispose of the instance.

The factory method avoids blindly allocating memory for objects that might not be used.

ReadWrite,readonly,assign,retain,copy,nonatomic properties function

@property is a property access declaration that supports several properties within the extension:

1,getter=gettername,setter=settername, set the method name of setter and getter

2,readwrite,readonly, setting the available access level

The 2,assign,setter method is assigned directly, without any retain operation, in order to solve the problem of the original type and the circular reference

3,retain,setter method to release old values of parameters and then retain new values, all implementations are in this order (CC has relevant information)

4,copy,setter method copy operation, as with the retain process, the old value of release, and then copy the new object, Retaincount is 1. This is the mechanism introduced to reduce dependency on the context.

Copy is used when you don't want a and b to share a piece of memory. A and B each have their own memory.

5,nonatomic, non-atomic access, no synchronization, multi-threaded concurrent access improves performance. Note that if you do not add this property, the default is two access methods are atomic transaction access. The lock is added to the owning object instance level (as I understand ...).

Atomic and nonatomic are used to determine whether the compiler-generated getter and setter are atomic operations. In a multithreaded environment, atomic operations are necessary, otherwise they may cause incorrect results. Adding the Atomic,setter function will change to the following:

Prefix for iOS attributes or variables-Miscellaneous

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.