Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"self" not available in debugger on iOS 5.1

Tags:

ios

debugging

I'm trying to debug a problem running under iOS 5.1 and when I stop in the debugger inside the code that gets the error and try to print something with the debugger I get the message:

error: warning: Stopped in a context claiming to capture an Objective-C object pointer, but 'self' isn't available; pretending we are in a generic context

Excuse me? Does anybody know what I've done to myself here?

The code is way too complicated for anybody to want to look it -- I'm mostly hoping somebody can tell me what the debugger message means.

This used to fail only intermittently but now fails mostly. The operation generally (or maybe always) works the first time I try it in iOS 5.1, occasionally after the first time, and apparently always works in iOS 6.

If it helps to know the general context ... I'm trying to add a just-written object to an ALAssetsGroup so this is in a completion block on a non-UI thread. I have a sensible-looking stack backtrace for a completion block. The failure is because the stored ALAssetsGroup no longer has a meaningful value -- or so says an NSLog of it that knows that it is an ALAssetsGroup object. This value is assigned in one place (and logged so I track that) and I can see the initial assignment with key-value observing and I don't see it ever being changed in a KVO-sorta way.

like image 887
Charlie Price Avatar asked Apr 05 '13 22:04

Charlie Price


2 Answers

In Build Settings, setting Precompile Prefix Header to NO fixed it for me.

like image 107
Mojo66 Avatar answered Sep 23 '22 17:09

Mojo66


This is a debugger bug (Yeah, imagine that!)

Simply restart XCode, and it shouldn't be a problem for you anymore :)

EDIT:

Psyche! I was thinking of something else.

You're creating a retain cycle, and as of now, the debugger classifies this specific retain cycle this way (As I said, a bug).

To fix this, create a weak copy of self:

__weak __typeof(self)weakSelf = self;

Then for the self that's giving you trouble:

Change self.object to weakSelf.object

like image 41
jakenberg Avatar answered Sep 26 '22 17:09

jakenberg