Block uses copy modifier

Copy copies blocks from the stack to the heap. What happens?

First declare the following in the Person class:

Three kinds of block

  1. No external variables are used in blocks

  1. Blocks use external variables

Similar:

  • NSStringWhether to usecopyorstrongTo modify?
    Immutable string

As you can see, for immutable strings, both strong and copy strings refer to the address of the original NSString.

NSMutableString

Mutable string

copy
NSString

Copy and strong

copy