★ TouchArcade needs your help. Click here to support us on Patreon.

Help with some terms

06-14-2009, 02:28 AM
#1
Joined: Mar 2009
Location: Singapore
Posts: 1,770
Send a message via AIM to kohjingyu
Help with some terms

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?
06-14-2009, 02:36 AM
#2
Quote:
Originally Posted by froggy1233 View Post
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?
1 = 1
1 = 1 = 1

SQLite3: http://en.wikipedia.org/wiki/SQLite

06-14-2009, 02:45 AM
#3
Joined: Mar 2009
Location: Singapore
Posts: 1,770
Send a message via AIM to kohjingyu
Quote:
Originally Posted by Spotlight View Post
1 = 1
1 = 1 = 1

SQLite3: http://en.wikipedia.org/wiki/SQLite
I mean like what's the difference between something = something and something == something.
06-14-2009, 03:51 AM
#4
Joined: Apr 2009
Location: Munich
Posts: 384
Send a message via Skype™ to rdklein
= 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.

RadioactivityCounter on App Store developer of this App RadioactivityCounter 2012
Ports of Call on App Store developer of this game 1986-2009,
06-14-2009, 06:45 AM
#5
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.
06-16-2009, 10:20 PM
#6
Joined: Apr 2009
Posts: 277
If you don't know the difference between = and ==, you should study basic C syntax before you try to develop a app.
06-17-2009, 06:10 AM
#7
Joined: Dec 2008
Location: The Land of The Rising Sun
Posts: 146
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.

Developer of Petri. Available now on the iTunes Store.

These days I work with Tonchidot on Sekai Camera.
06-17-2009, 06:43 AM
#8
Joined: Mar 2009
Location: Singapore
Posts: 1,770
Send a message via AIM to kohjingyu
Thanks guys!
06-17-2009, 10:29 AM
#9
Joined: May 2009
Location: Austin, TX
Posts: 199
Quote:
Originally Posted by gillygize View Post
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];

Developer at IMAK Creations, creator of ColorTilt and other lesser known apps, like That Ain't It!
Blog, twitter