Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Must explicitly describe intended ownership of an object array parameter" mean and how can I fix it?

There is something 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 fails with the error "Must explicitly describe intended ownership of an object array parameter".

What is the exact cause of the error? How can I fix it?

like image 960
itenyh Avatar asked Feb 20 '23 16:02

itenyh


1 Answers

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

  • __strong
  • __weak
  • __unsafe_unretained
  • __autoreleasing

I think in your case __unsafe_unretained should work, assuming that you do not do anything to the shapes that you pass to draw() concurrently.

void draw(__unsafe_unretained id shapes[], int count)
{
    for(int i = 0;i < count;i++) {
        id shape = shapes[i];
        [shape draw];
    }
}
like image 166
Sergey Kalinichenko Avatar answered May 07 '23 07:05

Sergey Kalinichenko