Hi,
Yavor Doganov wrote:
Good practice is to check the result of that assignment. If it fails for
some reason, it would explain (to an extent) why your program crashes
when you attempt to assign a value to the ivar at line 168. Also, if
self is nil, -retain will do nothing.
exactly, this is exactly what I was proposing. I assume the code listed
was more trimmed example, but:
- (id)initWithFrame:(NSRect)frameRect
{
NSLog(@"initWithFrame ...");
self = [super initWithFrame: frameRect];
if (self)
{
/* your code here */
}
return self
}
most usually it makes no real difference, if the init code does not have
some special code that can fail. However it can help track down things.
E.g. if here self is "nil" your problem is in the super class, but your
subclass is working on a bad object (of course: if it is "nil" all calls
should do nothing, it should not crash.. but accessing an structure is
usually invalid, e.g. a NSPoint! with GCC it will crash on most
architectures.
Thus it is importat to check your "nil" objects in the whole chain.
Riccardo
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep