Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

blueillusion

macrumors member
Original poster
Aug 18, 2008
56
3
I have some sort of problem.

Im making a bitmap library, and all works pretty well at the moment.
however, i have one problem when i initialize the class with an invalid bitmap.

I have a method called initWithContentsOfBitmap: (NSString *)path;

This method does:
self = [super init];
After that, it goes on to allocate some composite objects, and then calls loadBitmapFromFile: (NSString *)path;, where path is supplied from initWithContentsOfBitmap.

What i want, is when the path is invalid, i want the object to destroy itself before returning nil. Once the path is invalid, i can get initWithContentsOfBitmap to destroy all the objects it created, but im not sure out to get it to destroy itself without giving it the autorelease command.

Any ideas?
 
If you return nil right away, it is safe to call [self release] from within -init. That's why we typically check for [super init] != nil.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.