With.h
changeset 16 ce9c83f7ec14
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/With.h	Sun Jul 13 10:45:42 2008 -0700
     1.3 @@ -0,0 +1,21 @@
     1.4 +//
     1.5 +//  With.h
     1.6 +//  MYUtilities
     1.7 +//
     1.8 +//  Copyright 2008 Jens Alfke. All rights reserved.
     1.9 +//
    1.10 +
    1.11 +#import <Cocoa/Cocoa.h>
    1.12 +
    1.13 +
    1.14 +#define WITH(OBJ)       id __with=[OBJ beginWith]; @try
    1.15 +
    1.16 +#define ENDWITH         @finally{[__with endWith];}
    1.17 +#define CATCHWITH       @catch(NSException *x){id w=__with; __with=nil; _catchWith(w,x);} @finally{[__with endWith];}
    1.18 +
    1.19 +void _catchWith( id with, NSException *x );
    1.20 +
    1.21 +@interface NSAutoreleasePool (With)
    1.22 ++ (NSAutoreleasePool*) beginWith;
    1.23 +- (void) endWith;
    1.24 +@end
    1.25 \ No newline at end of file