Re: @try/@catch() compile question.
Re: @try/@catch() compile question.
- Subject: Re: @try/@catch() compile question.
- From: Fritz Anderson <email@hidden>
- Date: Sat, 05 Mar 2011 18:39:50 -0600
On 5 Mar 2011, at 6:22 PM, Clark Williams wrote:
> I have made certain the Foundation.framework/NSException.h framework is available to the project and that Allow Exceptions are enabled in the project settings.
NSException.h is a header, not a framework. Foundation is a framework. NSException.h is part of Foundation, and therefore available to you if you just #import <Foundation/Foundation.h>.
> I have the following code fragment within a method:
> ...
> @try {
> NSLog ( @"try" );
> } @catch ( NSRangeException *re ) {
> NSLog ( @"caught a: %@", [re name] );
> }
> ...
> I get the following errors on the @catch line:
> MainViewController.m:1206: error: expected declaration specifiers or '...' before 'NSRangeException'
> MainViewController.m:1206: error: '@try' without '@catch' or '@finally'
If you examine NSException.h, you'll see the declaration
> FOUNDATION_EXPORT NSString * const NSRangeException;
Note that NSRangeException is not the name of a class or of any other data type; it is a string constant. You can't use it in the place of a type name in a @catch clause. I think what you mean is NSException. NSRangeException is one of the things [anException name] might turn out to be; you'd have to test for it.
When my implementations go above 1000 lines, I take it as a sign that I should do some serious refactoring; but you know your business.
— F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden