OBJECTIVE-C Study Notes 3

Source: Internet
Author: User

OBJECTIVE-C code block multiple concurrency

1. The code block object is an extension of a function in the C language, except for the code in the function, which also contains a variable binding, and the code block is sometimes called a closure

2. The code block contains two types of binding, the automatic binding uses the stack space, the managed binding uses the space

3. code block is not part of the ANSI C language standard

4. The code block features are as follows 1. The return type can be manually declared or it can be automatically deduced by the compiler, with a parameter list of the specified type, with a name, and an instance of the code block as follows

void (^ code block name) (parameter type parameter);

5. The code block is implemented as follows

void (^ code block name) (parameter type parameter) = ^ code block name

{

code block Implementation

}

6. The code block only needs the ^ symbol when it is defined, and can be used as a general function when used

7. Blocks of code can access valid variables created at the same time as he

8. Use typedef keyword to simplify code block definition

typedef double (^ code block name) (parameter list)

Then you can code block name code block instance = ^ (parameter list) {implementation}

9. Code blocks can access variables of the standard type used by the function, including local variables, global variables, parameter variables and _block variables, local variables inside the code block

10. Local variables are obtained as constants by blocks of code, that is, they cannot be modified, and they must be declared as modifiable if they want to modify the values _block

11. Some variables cannot be declared as blocks, including variable-length arrays, structures containing variable-length arrays

12. Apple introduces GCD technology for system-level thread management

[Email protected] You can protect your code in critical areas

14. If you define a property that does not specify a keyword nonatomic, the compiler automatically generates a Getset method that is mutually exclusive, and you can use the @nonatomic keyword to specify the mutex level

15. Want to have a piece of code in the background to perform the Performselectorinbackground:withobject method that can use NSObject

16. A method that executes in the background cannot have a return value, or only one parameter, or no parameter

The scheduling queue of the 17.oc is divided into three kinds, namely continuous queue, concurrent queue, home row, continuous queue according to FIFO principle, concurrent queue is executed by priority, but the task volume of one run is indeterminate, can specify three priority of concurrent queue is high low default, If you want to get priority, using the Dispatch_get_global_queue method, the results are Dispatch_queue_proority_high dispatch_queue_proority_low DISPATCH _queue_proority_default

18. Get the current queue Dispatch_get_current_queue

19. Queue scheduling is best used for code blocks

20. Post-multithreading things to add

OBJECTIVE-C Study Notes 3

Related Article

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.