4

I was looking through some Apple sample code for their 2014 WWDC session 'Advanced User Interfaces with Collection Views' and came across a weakself declaration that looked like the following:

__weak typeof(&*self) weakself = self;

My question is: what do the &* mean in the declaration? Why not just have:

__weak typeof(self) weakself = self;

Thanks for your help.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Stefan Church
  • 1,351
  • 1
  • 10
  • 14

2 Answers2

0

Why not just have:

__weak typeof(self) weakself = self;

You can. This is the normal way to do it. Some previous version of the compiler didn't handle it properly, but that was fixed a long time ago.

newacct
  • 119,665
  • 29
  • 163
  • 224
-1

self is a MyInstance *. When you say *self, you're dereferencing the self* getting back self. Then when you take the &(*self) you're grabbing the memory address.

Oxcug
  • 6,524
  • 2
  • 31
  • 46