Skip to content

Instantly share code, notes, and snippets.

Last active December 17, 2015 10:29
What would you like to do?
weak self

There really needs to be an easier way to do this built into the language, but until then, I use my handy CodeBox app to paste in this whenever I need a weak reference to self:

__weak typeof(self) celf = self;
[self block:^{ = bar;

It's a nifty trick, but Apple, please... I shouldn't have to declare a weak self, I should be able to use self with a predefined symbol for "self" that the compiler will then write the weak self declaration for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment