Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Self-Destructing Message iPhone App Capturing Photo and Video Using UIImagePickerController Uploading the File and Message

Michael Liquori
Michael Liquori
8,131 Points

[[NSError init] alloc]; does not work, here is my solution, but why?

The way Ben tests the error handling in the video:

error = [[NSError init] alloc];

causes a runtime error for me.

Here is what did work:

error = @"1";

Can anyone provide more info as to why this is?

Is this a general change in how the language operates now?

Thanks!

1 Answer

Stone Preston
Stone Preston
42,016 Points

are you sure he doesnt use:

error = [[NSError alloc] init];

instead of

error = [[NSError init] alloc];
Michael Liquori
Michael Liquori
8,131 Points

Doh! you are right Stone Preston , thank you, how embarrassing.