• 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
@try @catch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

@try @catch


  • Subject: @try @catch
  • From: Georg Seifert <email@hidden>
  • Date: Thu, 14 Aug 2008 12:58:21 +0200

hello,

is it recommended to use @try .. @catch blocks as flow control like it is used in Python. They say explicitly to use it rather than do a lot of test before just try if it works to look after it only if it fails.

I could imagine something:
- (id) layerInstance {
	if ([[layerInstancesController selectedObjects] count] > 0) {
		return [[layerInstancesController selectedObjects] objectAtIndex:0];
	}
	return nil;
}
to look like:

- (id) layerInstance {
	@try {
		return [[layerInstancesController selectedObjects] objectAtIndex:0];
	}
	@catch {
		return nil;
	}
}

it should run faster if I do not have the if clause? Or are there any drawbacks?

Regards
Georg
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: @try @catch
      • From: Andrew Farmer <email@hidden>
    • Re: @try @catch
      • From: Uli Kusterer <email@hidden>
    • Re: @try @catch
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: CoreData, Object/Array Controllers and KVO
  • Next by Date: Updating current managedobject
  • Previous by thread: Re: CoreData, Object/Array Controllers and KVO
  • Next by thread: Re: @try @catch
  • Index(es):
    • Date
    • Thread