|Jan 31, 2013, 05:37 PM||#1|
New Objective-C Tutorial
Hey iOS devs!
I just published a comprehensive Objective-C tutorial at: http://rypress.com/tutorials/objective-c/
I thought it would be a very useful reference for the beginning developers hanging around the MacRumors forums.
If any experienced programmers have the time to read through it (or part of it) over the next few weeks, feedback would be greatly appreciated.
|Feb 1, 2013, 12:39 AM||#2|
I read the section on Errors and Exceptions.
I have to confess, I've never use any error/exceptions in Obj-C... and the excessive use of them is what makes me call C++ and Java ugly languages.
Is there any situation in which it'd be appropriate to actually @throw an exception?
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
|Feb 1, 2013, 01:29 AM||#3|
@throw is useful if you're writing a public library for others to use, since it lets the programmer know when they passed an invalid argument, when an internal state has been corrupted, or when something else has gone fatally wrong and the app needs to crash.
In application code, you should pretty much always use NSError instead of NSException.
I'll be sure to edit the tutorial to make that clearer. Thanks!
|Feb 1, 2013, 02:08 AM||#4|
Just to follow up on exceptions -- I generally look to the built-in frameworks and APIs to get a sense of what idiomatic iOS code should look like.
In that sense using exceptions to throw errors across a library boundary looks very unusual.
Your tutorial looks very detailed; I will have a proper look later
|Feb 1, 2013, 02:24 AM||#5|
I was actually thinking of it from that perspective. For example, when you try to access an NSArray element that doesn't exist, it throws an exception so you know you did something bad.
To clarify, you shouldn't ever use @throw to communicate an *error* across a library boundary, but it would be appropriate for a library to throw an *exception* for the programmer to catch.
Correct me if I'm wrong, and let me know if you have any other feedback. Thanks!
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|imovies tutorial ??||Sriteja25||MacBook Pro||3||Sep 11, 2013 04:00 PM|
|Picstitch Tutorial?||hewhodareswins||iPhone/iPad Programming||2||May 23, 2013 09:00 PM|
|Imovie Tutorial Anyone?||mortmonster||Mac Basics and Help||8||Oct 29, 2012 03:39 PM|
All times are GMT -5. The time now is 03:14 AM.