You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
619 B
Objective-C

#import "MyException.h"
#include <stdlib.h>
@implementation MyException
- (MyException *)initWithName:(char *)name
reason:(char *)reason
{
_name = name;
_reason = reason;
return self;
}
+ (void) raise: (char *)name
format: (char *)reason
{
MyException *e = [[[MyException new] initWithName:name
reason:reason] autorelease];
[e raise];
}
- (void) dealloc
{
if (_name) {
free(_name);
}
if (_reason) {
free(_reason);
}
[super dealloc];
}
- (void) raise {
@throw self;
}
- (char*)name
{
return _name;
}
- (char*)reason
{
return _reason;
}
@end