Question

I have an error with NSString. In one of my .m files I have a member called "conversions" of type NSString and within a method of that class the string is manipulated and added on to and etc. Well, when I try to Log that string in a different method that is later called, for some reason the string is printing as a UITouch object. Specifically, I try to log the string as follows

NSLog(@"%@", conversions);

and in my console it prints

<UITouch 0x131700> phase: Ended tap count: 1 window: <UIWindow: 0x136470; frame = (0 0: 320 480) opaque = NO.....(and more property type stuff)

Why has my NSString turned into what looks like a UITouch object? What is going on?

Was it helpful?

Solution

A likely cause for problems like these is that "conversions" got released too early, thus got deallocated and you were still holding a reference to that memory location. Then another object got allocated at this location.

To debug this, set NSZombieEnabled. It doesn't deallocate objects but replaces them with "zombies". See for example the following link:

http://www.tomwhitson.co.uk/blog/2009/04/debugging-with-nszombiesenabled/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top