Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mrat93

macrumors 68020
Original poster
Dec 30, 2006
2,352
3,419
First of all, please keep in mind that I am a TOTAL beginner to programming, hence why I bought "iPhone and iPad Apps for Absolute Beginners."

I'm trying to create the first "Hello World" app in the book.

I copied the following code from the book which is in the ViewController.m class:

Code:
#import "hello_world_1ViewController.h"

@implementation hello_world_1ViewController
- (IBAction)hello:(id)sendr{
	label.text = @“Hello World!”;
}

However, I'm getting seven errors when trying to run it.

Sorry for sounding like a complete idiot, but can anybody help me out?
 
1. Always post the errors you see. Copy and paste them. Accuracy is important.

2. When you post a .m file, always post its corresponding .h file. Showing the .m alone is only half the story. The other half is the .h.

3. Copying and pasting from ebooks can be risky. You have "curly" quotes in your posted code. These won't compile.
http://en.wikipedia.org/wiki/Quotation_mark_glyphs

4. When a book has an accompanying download of source files, always use it. This avoids problems arising from copying and pasting curly quotes.
http://apress.com/book/downloadfile/4588

Examples of curly and "straight" quotes, enlarged and hilited in red to make it easier to see the difference:
Code:
[SIZE="5"]label.text = @[COLOR="Red"]“[/COLOR]Hello World![COLOR="Red"]”[/COLOR];[/SIZE]
Code:
[SIZE="5"]label.text = @[COLOR="Red"]"[/COLOR]Hello World![COLOR="Red"]"[/COLOR];[/SIZE]
 
3. Copying and pasting from ebooks can be risky. You have "curly" quotes in your posted code. These won't compile.
http://en.wikipedia.org/wiki/Quotation_mark_glyphs

Not that you asked, but I disagree with your #3 in certain cases. I find typing the code to be a useful method of helping me learn (or at least think about) each line of code.

For instance in this case, the original poster has learned that there's a difference between various quotes, and that that difference is important.
 
Not that you asked, but I disagree with your #3 in certain cases. I find typing the code to be a useful method of helping me learn (or at least think about) each line of code.

Typing the code is not copying and pasting.

In my experience, someone typing code from a book (or ebook) will type in the straight quotes, because that's what's on the keyboard. Same thing for straight single-quote (apostrophe).

I even see this when the character is the accent grave, which has a distinctly different meaning in, say, shell scripts, than does the straight single-quote.
 
first guess: it's sender not sendr... while this is not all, most errors come up because you have errors before that.. so always check the FIRST error in your code!

post you complete code, otherwise we cannot help you..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.