If I release an instance of NSOperation before sending -init to it I get a segmentation fault.
Reasons I think this is valid code:
- Apple does this in its documentation.
- Gnustep does it in its
implementation of NSNumber, so it's fairly certain that this is in Apple's code too. (At least was.) NSObjects-initdoesn't do anything, therefore-release, which belongs toNSObjectshould be working before that.
// gcc -o test -L/System/Library/Frameworks -framework Foundation test.m
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
NSOperation *theOperation = [NSOperation alloc];
[theOperation release];
}
- What do you think, is this a bug?
- Can you show me an example of another class that has the same behavior?
- Any idea why this is happening?