• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re: Re: try/catch/throw/finally example?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Re: try/catch/throw/finally example?


  • Subject: Re: Re: Re: try/catch/throw/finally example?
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 25 Aug 2006 16:24:10 -0700

On 8/25/06, Keith Ray <email@hidden> wrote:
I noticed that even though the compiler doesn't complain about about a
missing catch block, if it *is* missing, the finally block is never
executed.


@try { [stringOne appendString:stringTwo]; } @finally { NSLog(@"This always happens."); }

I have never seen that and it would be a major compiler bug if it did. You have an example of that shows this?

---

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   NSString *stringOne = @"One";
   NSString *stringTwo = @"Two";

   @try {
       [stringOne appendString:stringTwo];
   } @finally {
       NSLog(@"This always happens.");
   }

   [pool release];
   return 0;
}

[Session started at 2006-08-25 16:22:15 -0700.]
2006-08-25 16:22:15.427 Test[19569] This always happens.
2006-08-25 16:22:15.428 Test[19569] *** Uncaught exception:
<NSInvalidArgumentException> Attempt to mutate immutable object with
appendString:

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >try/catch/throw/finally example? (From: Roland Silver <email@hidden>)
 >Re: try/catch/throw/finally example? (From: Todd Yandell <email@hidden>)
 >Re: Re: try/catch/throw/finally example? (From: "Keith Ray" <email@hidden>)

  • Prev by Date: Re: Re: try/catch/throw/finally example?
  • Next by Date: Newbie question of the day.
  • Previous by thread: Re: Re: try/catch/throw/finally example?
  • Next by thread: Re: try/catch/throw/finally example?
  • Index(es):
    • Date
    • Thread