Short Answer: The crash is a result of a stack overflow because your description method calls itself repeatedly. To do what you want to do (accessing the ivar from within the description method), you should not use the prefix self in front of the ivar.
Short Answer: The crash is a result of a stack overflow because your -description method calls itself repeatedly. To do what you want to do (accessing the ivar from within the description method), you should not use the prefix self. In front of the ivar.
More Detail: In Objective-C, self. Description is shorthand for self description. Using the dot-syntax informs the compiler that you want to access a property named description, and not the ivar itself.
Thanks, I knew I was doing something stupid. – Shiun Dec 16 '10 at 20:12 this? Think you mean self ;-) (Though this is the C++ equiv, sorta).
Nm, you fixed it. – NSGod Dec 16 '10 at 20:14 @NSGod: Already fixed, but thank you for pointing it out. I make that mistake all the time.
I cut my teeth on C++, so this pops out automatically :) – e. James Dec 16 '10 at 20:17.
It's an issue because you're creating an infinite loop. Self. Description will call self description, which is exactly the method you're within.
Hence you have the method calling itself repeatedly. - (NSString *) description { NSMutableString *output = NSMutableString string; output appendFormat:@"super's description = %@\n", super description; output appendFormat:@"MyObject. Description = %@\n", description; return output; } You can access the instance variable directly, rather than using self.description.
Also, I added an extra line to show how you can call super's description method (which doesn't create an infinite loop).
Thanks! That's the problem. – Shiun Dec 16 '10 at 20:13 +1 from me.
Good point about the call to super description – e. James Dec 16 '10 at 20:15.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.