• 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
Exception handling: confused by syntax
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exception handling: confused by syntax


  • Subject: Exception handling: confused by syntax
  • From: Mario Diana <email@hidden>
  • Date: Fri, 13 Sep 2002 09:25:31 -0400

Hello,

I'm confused by how to handle exceptions. The two Cocoa books I own are of no help, and what I've come across on the archives is not complete enough for me to make sense of.

My code could throw an NSInvalidArgumentException under some conditions. I know how I will handle the exception, I just don't know how to code catching it.

If it were Java, I'd do this:

public void myMethod() {
try {
// do the thing...
}
catch (NSInvalidArgumentException iae) {
// handle the error...
}
}

Okay, I see the NS_DURING, etc., but I'm just lost -- really! Would somebody please be kind enough to recode the above method for Cocoa in Objective-C? And, I'm a bit embarrassed to ask this, but code everything: especially, the variables I have to declare at the top of the block (if any).

This one little thing is driving me crazy.

Many thanks,

Mario Diana
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Exception handling: confused by syntax
      • From: Nathan Day <email@hidden>
  • Prev by Date: NSUserDefaults and NSArray
  • Next by Date: Re: NSUserDefaults and NSArray
  • Previous by thread: Re: NSUserDefaults and NSArray
  • Next by thread: Re: Exception handling: confused by syntax
  • Index(es):
    • Date
    • Thread