Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Its a great book. I was not smart enough to start with Object C, to much and it was confusing. Once I grasped C, the transition was less painful.

If you like that book and you think the next one in the series would be good, don't do it. It is written by a different author and is not nearly as good as the one you are reading now. There are other good options.

Continuing to learn I am reading through a book called "Clean Code" to help me develop better coding habits and styles.

I found so for that programming is something you never master, you just get better and better at it the more you work with it.

I assume the book you're referring to here is "Learn C on Mac" ?

I am enjoying the book - the aorthur is clear and makes sure you understand what;s plotting.

Like you - I could get Objective-C down - and I hated the fact that I did not understand some of the code.

I will read "Clean code" too at some point, thank you for that suggestion. :D

At the moment I have just done a few basic console based programs and already I feel I can excel in this world.

I also, agree with you - programming is not something you could ever master - just constantly improve upon it.
 
I assume the book you're referring to here is "Learn C on Mac" ?

I am enjoying the book - the aorthur is clear and makes sure you understand what;s plotting.

Like you - I could get Objective-C down - and I hated the fact that I did not understand some of the code.

I will read "Clean code" too at some point, thank you for that suggestion. :D

At the moment I have just done a few basic console based programs and already I feel I can excel in this world.

I also, agree with you - programming is not something you could ever master - just constantly improve upon it.

Ya it is the same book. The first 3/4 of the book were pretty straight forward. Later he starts to build some DVD project that goes in to other chapters. That started getting harder and I started slowing down. Structs I think was an issue and even today I sometimes get lost.
Stick with that book and take your time.

Like I mentioned before. When you are done write a BlackJack game from scratch. That asks for the users name, would you like to play again? and solve the A's as 11 or 1. It took me about a week and was a good challenge.
 
Ya it is the same book. The first 3/4 of the book were pretty straight forward. Later ... That started getting harder and I started slowing down.

You don't learn programming just by reading. Put the book down and write some of your own programs using what you just read. Then, when you pick the book back up, the later parts will read less slowly.
 
You don't learn programming just by reading. Put the book down and write some of your own programs using what you just read. Then, when you pick the book back up, the later parts will read less slowly.

Pretty much what larswik actually did. At the end of every chapter he was here with some element of a program that was interesting to him that drew from the book.

Learn C on the Mac is really quite short, IMO there isn't much there there.

B
 
Pretty much what larswik actually did. At the end of every chapter he was here with some element of a program that was interesting to him that drew from the book.

Learn C on the Mac is really quite short, IMO there isn't much there there.

B

HAHA... My eyes opened up when I read firewoods response. Thinking wow if he only knew that is what I did for every chapter. Then to read your post balamw who was a big resource in that time helping me through that stuff, and still helping me today! Lee, Chown33, jiminus and the grumpy guy gnasher729 :) I really like this board!
 
You don't learn programming just by reading. Put the book down and write some of your own programs using what you just read. Then, when you pick the book back up, the later parts will read less slowly.

This is what I am doing at the moment.

At the end of every chapter - I write my own small program, trying to combine all the previous work in that one program. It helps a lot and I keep practicing typing and learning the code.

So some of you say this book is too short and doesn't give enough on the C language?
 
Ya, you are mirroring me. I tried to create little games if I could to keep it fun. If you don't get something, re read the chapter before going on and ask questions here.

By the way, I don't want to through you off from learning but I found it more fun to create little games and tests when the computer could generate a random number. The code is pretty easy to integrate.

int randNum = rand() % 100 + 1;

This code will create a random number from 1 to 100. If the +1 was not there it would generate a number from 0 to 99 which is what you would use when selecting indexes in arrays since indexes start at 0. (actually it generates a number from 0 to 99 but you add 1 to the result with + 1. If u simulate dice 0 is not a number so 0 to 5 would be 1 to 6).

All you have to do is change the 100 number to what ever you want (within the int range of course) so you can get 0 to what ever number you pick.

I used this to have it give Yes or No answers in an If-Else. Pick a number from a deck of cards in an array, use a 'for' loop and iterate it 10000 times and count how many times it picks the number 7 out of 100. Or you pick a number and use a while loop to count how many loops it takes to guess your number before it exists. Have it generate a secret number and use scanf to enter the number you think it is. Then use the < > operators to tell you if the number you guessed was to high or to low.

It gives the results a bit of randomness which was fun and helps you better see what the code does. That is why I created a Blackjack game at the end to test my skills.
 
A good thing to do when trying to learn something new new is to get several books on the same topic. It's especially true when learning programming, because people who write those books are usually expert coders and take many things for granted. Chances are that one crucial thing that is missing in one book has been covered in another.
 
I call this the "salad bar" approach. It works well for me, but is not for everyone.

Yeah i wasn't a big fan of this method. I bought two Obj-C books but found that using them simultaneously wasn't working very well. Or it could be that i just disliked the Big nerd ranch book, im not quite sure :confused:
 
Ya, you are mirroring me. I tried to create little games if I could to keep it fun. If you don't get something, re read the chapter before going on and ask questions here.

By the way, I don't want to through you off from learning but I found it more fun to create little games and tests when the computer could generate a random number. The code is pretty easy to integrate.

int randNum = rand() % 100 + 1;

This code will create a random number from 1 to 100. If the +1 was not there it would generate a number from 0 to 99 which is what you would use when selecting indexes in arrays since indexes start at 0. (actually it generates a number from 0 to 99 but you add 1 to the result with + 1. If u simulate dice 0 is not a number so 0 to 5 would be 1 to 6).


All you have to do is change the 100 number to what ever you want (within the int range of course) so you can get 0 to what ever number you pick.

I used this to have it give Yes or No answers in an If-Else. Pick a number from a deck of cards in an array, use a 'for' loop and iterate it 10000 times and count how many times it picks the number 7 out of 100. Or you pick a number and use a while loop to count how many loops it takes to guess your number before it exists. Have it generate a secret number and use scanf to enter the number you think it is. Then use the < > operators to tell you if the number you guessed was to high or to low.

It gives the results a bit of randomness which was fun and helps you better see what the code does. That is why I created a Blackjack game at the end to test my skills.


I'm not that far into the book just yet - but will take your suggestions when I do get there. :D

I will finish the book first and if I feel I need to know more on C I will look at other books - but I see myself going straight to objective C afterwards and going from there.

How hard is it to make games for the iPhone and iPad by the way? (Thinking all those graphics will be a challenge in it self..?

I was thinking - can we keep this topic alive for all new comers to the programming world - this single thread has more information, advise and real world experience from other guys than anywhere else I have found on the net. I think it would be a great place to share ideas, learning styles etc with everyone.


I don't know, just idea, use it, don't use it. :cool:
 
I bought a game development book from Apress but stopped after a could chapters. It's a good book and I plan to go back to it at some point. There is so much to learn and know before I go into gaming.

Right now I am trying to learn more about different Classes and how they can help me. I would love a book that covers Classes. A short chapter per Class with tutorials, explanations. Just to day I saw something called and NSSet? No clue what that is yet.

Learning this stuff is a full time job but it is fun.
 
While I did post earlier to start with Programming in Objective-C 4th edition (which I still do highly recommend), I did fail to mention that years ago I did start with Dave Mark's Learn C on the Macintosh (not Mac, the older edition with the blue cover). That let me learn and grasp more of the programming concepts for a procedural language rather then the actual syntax itself, and I'm sure that made a big difference later on.

But, I'm still a firm believer that someone with decent Mac/computer skills can pick up Programming in Objective-C and be fine with it.
 
After that since I like that book so much I got the next one which was "Learn Objective C for absolute beginners" I think the title was. But the author was different and I did not finish the book because of many errors and it was bad. I also then took a programming class at my city college to reenforce what I was learning, Pascal. That class was probably the best thing for me. I learned about abstraction (which still confuses me from time to time), top down design, how to approach a problem you need to solve, keep things organized and simple so projects don't get out of control.

When you finish C and you get it, you will then have to unlearn a few things :) C us a procedural language and you will have to get use to using objects. But your C logic is the same. Objective C is built on top of C and it all works, at least from what I have learned.

Keep learning and ask questions here. Stupid questions are fine. God knows I still ask a lot of stupid questions here that you would figure you would learn on page 1 in an objective C book. haha

By the way what page are you on in Learn C?
 
Well I have found a bit of code that confuses me a little in the book - the author has explained as well as he could - but I believe there is an error in his code, so I changed it a little, played with it a little and now it's slightly clear - not much.

I have been told I will have to unlearn a few things from C - but I am okay with that. I will look for a few books before I start on objective - C.

Is it easier than C though or about the same?

I am not sure what page I am on - I think 110 - he is talking about logical operators. The "&&" and || operators - this is where my problem in understanding his code comes into play.

Also he talks about "flow-through" code and brakes - this is where I really had to follow - but I think I will just reread the whole section.

Where are you aiming to go with your programming skills? iOS development or more OS X side?

BTW: I appreciate your feedback and help - it really is an eye opener for me. :cool:
 
Well I have found a bit of code that confuses me a little in the book - the author has explained as well as he could - but I believe there is an error in his code, so I changed it a little, played with it a little and now it's slightly clear - not much.

Two things here:
1. Find the website for the book. Visit their forum. Ask book-specific questions there, such as if you think the code in the book has an error.
2. Vague descriptions are useless. Post code. Ask a specific question. This is true here as well as at the forum associated with the book.

I'm not sure at this point which book you mean by "the book". And you didn't post code or ask a specific question, so I can't offer more specific advice, either about clarifying the code or about finding a website forum for the book.
 
&& / || operators (and / or operators). My Pascal teacher had a good example for these in an IF statement.

If ((your home work is done) && (you took out the trash))
{
You can go to the movies.
}

Both the right and left side must be true in order for the If statement to execute. So the kid has to do both his home work and take out the trash.

If ((your home work is done) || (you took out the trash))
{
You can go to the movies.
}

In this case one or both has to be true. He had to do ether his homework or take out the trash to go to the movies. You can also look up Truth tables later and it will explain more. They can get more difficult to follow when you start to mix && and || or many &&'s. But you will use these in your programs so learn the basics of them.

As for me I have had my own business for 12 years now. I started to learn how to program because I wanted to add things to my business and add app creation to my list of services.

Just last night I uploaded my very first app to get approved at the app store. So in a way I have reached my goal and I started where you are now about 18 months ago give or take.

Now I can go to my favorite Deli which I wait in line 15 minutes to get a sandwich and say "You need me to make an app for you that I can order my sandwich and pick it up without waiting in line". I like both ios and Mac OS and they are pretty similar.

I think Apps are becoming the new Dot Com of the 90's. Back then everyone had to have a webpage. These days people are wanting apps but apps are harder to make then a webpage IMO.
 
Thanks guys I appreciate the feedback.
The book I am referring to is Learn C on Mac The code I was referring to is:

Code:
	bool    nothingElseOn, itsARerun;

	
	nothingElseOn = true;
	itsARerun = true;
	
	if ( nothingElseOn || (! itsARerun) )
		printf( "Let's watch Family Guy!\n" );
	else
		printf( "Something else is on or I've seen this one.\n" );

I ran through this code again in my head and in Xcode and get why it works and it was my understanding that was flawed - not the code. I was busy reading that part of the book when I was bit tired and not really focusing. But I understand the above 100% now.

My first goal is to get an app submitted to the store. :cool:

larswik - when you have time, I would like us to chat more - maybe on a different platform - not to clutter up this thread with random posts. :cool:
 
Cool. Privet messages work too. As for the code you understand what the "!" (called NOT) operator is doing. It just simply reverses a true to a false and a false to a true.

So,
Code:
int num = 5;
if (num == 5)
{
    do this
}
else
{
    do something else
}

In the case above it would execute the If statement because num is the same as the number 5 so it evaluates to TRUE. With an IF statement if the result is TRUE the IF statement is executed But,
Code:
int num = 5;
if (!num == 5)
{
    do this
}
else
{
    do something else
}
With the NOT operator it would reverse the result and execute that ELSE statement instead. In English it would read, "If num is NOT the same as 5". In that case num IS equal to the number 5 so it would execute the else statement instead.

Since num is the same as 5 the If statement would be TRUE and execute if statement. But that is where the NOT operator kicks in. It will take the TRUE result and turn it to FALSE result. If the result is FALSE the if statement will not execute, instead the ELSE is executed. If you have no ELSE it skips the if statement. I use these all the time in programing to make decisions.
 
Code:
int num = 5;
if (!num == 5)
{
    do this
}
else
{
    do something else
}
With the NOT operator it would reverse the result and execute that ELSE statement instead. In English it would read, "If num is NOT the same as 5". In that case num IS equal to the number 5 so it would execute the else statement instead.

Since num is the same as 5 the If statement would be TRUE and execute if statement. But that is where the NOT operator kicks in. It will take the TRUE result and turn it to FALSE result. If the result is FALSE the if statement will not execute, instead the ELSE is executed. If you have no ELSE it skips the if statement. I use these all the time in programing to make decisions.

This description is wrong. It doesn't match the code.

The reason is operator precedence, an important concept in any language, but especially important in C (and C-like languages) because of the large number of operators.

In this code:
Code:
if (!num == 5)
The ! operator has higher precedence than the == operator, so it's evaluated earlier.

Your description ""If num is NOT the same as 5" makes it seem like this is how it's evaluated:
Code:
if ( ! (num == 5) )
That is, as "If NOT (num is equal to 5)". But because of precedence, it really evaluates like this:
Code:
if ( (! num) == 5 )
which is "If (NOT num) is equal to 5". Then you have to ask yourself, "Exactly what does "(NOT num)" evaluate to? The rest of the comparison, "is equal to 5", has 5 as an integer number. So does "(NOT num)" have a numerical value? If so, what is that number?

As it turns out, the ! operator has a very simple numerical result: if its operand is 0, the result is 1; if the operand is non-0, the result is 0. In short, it converts 0 to 1, and any non-0 to 0.

In this case, the operand is the variable num, whose value is 5 (a non-0 value). So the result is 0, and 0 is then compared to 5. The result of that comparison is false.

It happens that this false outcome is the same as:
Code:
if ( ! (num == 5) )
or:
Code:
if ( num != 5 )
but it won't always work out that way. With different sub-expressions or different operators, the result may be different. Always use the simplest expression that accomplishes the goal.

I see no reason to use a more complex expression, when the one using != is simpler and has no precedence rules to bungle. It reads "If num not equal to 5", which seems eminently clearer and simpler to me.

Know your operator precedence. If you don't know it, look it up. Most C books also have a table somewhere in them, which also covers operator associativity (yet another trap for the unwary (or unparenthesized)).
 
Good Point. I did test the code before I uploaded it and it worked. I am aware of the precedence chart but I understand what you are saying. The != would be better to use in this example. In fact that was the original way I wrote it but was not sure he had covered the != yet. I then changed it to something that was a little easier to read and show that NOT operator by it's self.

Thanks for the clarification Cown33.
 
I have covered the != operator. I just need to understand the precedence and learn them, too.

Thanks to both of you - I now fully understand the NOT operator - but isn't their just an easier way of doing it - simpler?

I am going to re-read the last chapter to make sure I understand all the operators properly. :cool:

I was thinking, since I am in South Africa - could I make an app and load it to the USA store or am I only able to load it to the South African store (Or both? )
 
Thanks to both of you - I now fully understand the NOT operator - but isn't their just an easier way of doing it - simpler?

An easier way of doing what?

The operations and forms required for Boolean (logical) algebra are pretty well established if that is what you are tailing about.

The code you posted could by unrolled using nested if statements
Code:
bool    nothingElseOn, itsARerun;

nothingElseOn = true;
itsARerun = true;

if ( nothingElseOn)
    if (itsARerun) 
        printf( "I've seen this one.\n" );
    else    
        printf( "Let's watch Family Guy!\n" );
else
    printf( "Something else is on.\n" );

Is that simpler?

Cons. It is less efficient. requiring one more if statement.
Pros. It is (perhaps) more readable, and lets you tell the difference between the two reasons why you might not want to watch Family Guy tonight.

You should be able to submit your apps to any country Apple has an App Store in.

FWIW, it is preferable to keep this type of discussion in the public space, precisely so others can learn from it and still other can chime in.

B
 
No what I meant - why are we asking the complier to change the value using the ! operator.

Code:
itsARerun =false;

if ((!itsARerun)

This part of the code changes the false to true.

Why don't we just set it to true - why are we using the complier to change the value?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.