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

dieseltwitch

macrumors regular
Original poster
Jan 24, 2008
142
0
I'm learning to program, but I'm having trouble trying to get data into my app. I've been watching the Lynda Videos and they are very helpful. However, there are many times when its stated in an early video "we will cover that later" or "you don't need to know that for now" but its never covered... very frustrating. its like learning how to drive a car but then never being shown how to actually get it started. lol

What I'm looking for is some type of user input code. I want to write a simple app that takes in some data, say 3 or for numbers does some math on them and spits back out some result.
 
Get yourself a reference book to use along with lynda.

Is this Objective-C?

C's scanf is the standard way of dealing with input.

B
 
Thanks that works, for now;

Code:
 int myNumber;
        NSLog(@"Input:");
        scanf("%d", &myNumber);
        NSLog(@"Output: %d", myNumber);

I did a little search on scanf.

My next question is what does the & do in the scanf line?
 
Last edited by a moderator:
It passes the location, known as an address, of the variable 'myNumber' so that 'scanf' can place the requested value in the variable 'myNumber'.
 
Make sense.

Just checking, but the simple idea is the the & signifies the direction data is traveling in the program to the program its self?
 
No, it simply passes the address of the variable instead of the contents of the variable.

I'll amend that and say it does allow you to place thing into the variable from afar!
 
This discussion of pointers, passing by reference vs. passing by value, etc... is important for you to understand as it comes quite a bit with objects.

Not learning this up front is likely to give you heartache later. JMHO.

I think that Kochan is a better reference book, but Hillegass' new book http://www.bignerdranch.com/book/objective-c_programming_the_big_nerd_ranch_guide is a good source for the basic concepts.

B
 
This discussion of pointers, passing by reference vs. passing by value, etc... is important for you to understand as it comes quite a bit with objects.

Not learning this up front is likely to give you heartache later. JMHO.

B

I agree! I'm just having a hard time knowing when to use * or & or nothing at all... lol I get the idea of the point just the when to use what is giving me to use trouble. but thats why I'm learning it in Command Line programs rather then deeper programs
 
I agree! I'm just having a hard time knowing when to use * or & or nothing at all... lol I get the idea of the point just the when to use what is giving me to use trouble. but thats why I'm learning it in Command Line programs rather then deeper programs

That's why the two books I linked are Objective C, command line only. They have other books for Cocoa/Cocoa Touch. ;)

Structurally, a book will give you more context and reinforce concepts appropriately.

B
 
That's why the two books I linked are Objective C, command line only. They have other books for Cocoa/Cocoa Touch. ;)

Structurally, a book will give you more context and reinforce concepts appropriately.

B

I saw those and will see if I get any barns & noble or amazon gift card tomorrow ;) I found that the apple reference is a great place.... so long as you know what you looking for. Same problem as trying to figure out how to spell a word by looking it up in the dic... lol
 
This discussion of pointers, passing by reference vs. passing by value, etc... is important for you to understand as it comes quite a bit with objects.

Not learning this up front is likely to give you heartache later. JMHO.

I think that Kochan is a better reference book, but Hillegass' new book http://www.bignerdranch.com/book/objective-c_programming_the_big_nerd_ranch_guide is a good source for the basic concepts.

B

Out of those two books, what book would you recommend as a "read all book" rather then just a reference book?

I found it both in the iTunes book store and have a gift card for that!
 
Out of those two books, what book would you recommend as a "read all book" rather then just a reference book?

I found it both in the iTunes book store and have a gift card for that!

The Big Nerd Ranch Objective-C book will be the better one to get you started faster, once you finish it then go for the Kochan book which will be probably more useful in the long run.

You can never use just one book as they all have different approaches. If you are new to programming (which it sound like you are) go for the Big Nerd Ranch book.

That being said once you finish the book I wouldn't suggest jumping to the next Big Nerd Ranch book as they are not written for beginners (the Obj-C book is the only exception).

I guess what I'm saying is do this order:

1. Big Nerd Ranch Objective-C book
2. Steve Kochan Objective-C book
3. Big Nerd Ranch Mac OS Programming or iOS book (whichever you are going for).
 
The Big Nerd Ranch Objective-C book will be the better one to get you started faster, once you finish it then go for the Kochan book which will be probably more useful in the long run.

You can never use just one book as they all have different approaches. If you are new to programming (which it sound like you are) go for the Big Nerd Ranch book.

That being said once you finish the book I wouldn't suggest jumping to the next Big Nerd Ranch book as they are not written for beginners (the Obj-C book is the only exception).

I guess what I'm saying is do this order:

1. Big Nerd Ranch Objective-C book
2. Steve Kochan Objective-C book
3. Big Nerd Ranch Mac OS Programming or iOS book (whichever you are going for).

Thanks!
 

No problem. Just remember when programming that sometimes you have to skip over something confusing at first to understand it later.

If you run in to a lot of problems going through the first book, grab the second book and use it to supplement what you are learning in the first.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.