jens@0: // jens@0: // With.h jens@0: // MYUtilities jens@0: // jens@0: // Copyright 2008 Jens Alfke. All rights reserved. jens@0: // jens@0: jens@0: #import jens@0: jens@0: jens@0: #define WITH(OBJ) id __with=[OBJ beginWith]; @try jens@0: jens@0: #define ENDWITH @finally{[__with endWith];} jens@0: #define CATCHWITH @catch(NSException *x){id w=__with; __with=nil; _catchWith(w,x);} @finally{[__with endWith];} jens@0: jens@0: void _catchWith( id with, NSException *x ); jens@0: jens@0: @interface NSAutoreleasePool (With) jens@0: + (NSAutoreleasePool*) beginWith; jens@0: - (void) endWith; jens@0: @end