Hey guys, Can anyone explain to me when to use = and when to use ==? And what is the difference? Also, can anyone tell me what is SQLite3?
= is an assignment == is a comparison. You need to take a tutorial on C++ / C also Java is using the same an other languages, while Delphi, Pascal, Modula2 uses := for assignment and = to compare values.
int x=2; if(x==2) //do something thats the correct way to use it, x is assigned the value of 2, then x is asked if its equal to 2, then returns a true value which runs whats in the if block. had you done int x==2; nothing would have happened, (really this statement returns a false boolean but its not used for anything) had you done if(x=2) //do something x would have been assigned 2, the if condition would have been met and whatever is in its block would run everytime.
If you don't know the difference between = and ==, you should study basic C syntax before you try to develop a app.
You use = when you want to assign a variable a value. Hence, x = 2 <--now the variable 'x' has the value of 2 You use == when you want to compare two values to see if they are the same. Hence, x = 2; y = 2; x == y; <-- this is TRUE y = 3; x == y; <-- this is FALSE (x still has a value of 2 since we didn't change the value) SQLite is the best database tool for iPhone developers. You may want to use it if your app will be dealing with a lot of information.
If you use SQLite, you will also want to check out Jeff LeMarche's SQLite Persistent Objects, which you can read about on his blog. If you don't use SQLite, or don't want to, or want to be on the leading edge, then you should read up on Core Data. Also, to introduce some Cocoa syntax, to compare two NSNumber objects, you can use: Code: BOOL isEqual = [myFirstNumber isEqualToNumber:mySecondNumber];