What does it mean "Explicit description of the alleged ownership of an object array parameter" and how to fix it?

Something is wrong with the first line of the following function definition:

void draw(id shapes[], int count)
{   
    for(int i = 0;i < count;i++) {
        id shape = shapes[i];
        [shape draw];
    }
}   

Compilation failed with the error "Must explicitly describe the alleged ownership of an object array parameter."

What is the specific cause of the error? How can i fix this?

+3
source share
3 answers

You are passing an array of pointers in an ARC environment . You must specify one of the following values:

  • __ strong
  • __ weak
  • __ unsafe_unretained
  • __ autoreleasing

I think that in your case it __unsafe_unretainedshould work, assuming that you are not doing anything with the forms that you go through at the draw()same time.

void draw(__unsafe_unretained id shapes[], int count)
{
    for(int i = 0;i < count;i++) {
        id shape = shapes[i];
        [shape draw];
    }
}
+7

, , , , __unsafe_unretained, , , Strong var unsafe_unretained. __strong .

void draw(__strong id shapes[], int count)
{
    for(int i = 0;i < count;i++) {
        id shape = shapes[i];
        [shape draw];
    }
}
0

- ARC Xcode.

, LLVM Apple 8.1 - Objective-C . .

0

All Articles