Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-26-2009, 06:37 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
starwarsdevwookie59 is on a distinguished road
Default basing an action on different values

Ok i figure this should be simple, but for the life of me I can't figure out how to make one action do something if different values are true, without using a BUNCH of if statements. Example:

if (float1 == 3){
action1;
}
if (float2 == 3){
action1;
}

But i want to put that into one code, so works like this:

if (float1 or float2 ==3){
action1;
}

Once again, I realize this should be easy, but I just can't seem to figure out the code. Any help would be much appreciated.
starwarsdevwookie59 is offline   Reply With Quote
Old 05-26-2009, 06:40 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 160
Vortec4800 is on a distinguished road
Default

Quote:
Originally Posted by starwarsdevwookie59 View Post
Ok i figure this should be simple, but for the life of me I can't figure out how to make one action do something if different values are true, without using a BUNCH of if statements. Example:

if (float1 == 3){
action1;
}
if (float2 == 3){
action1;
}

But i want to put that into one code, so works like this:

if (float1 or float2 ==3){
action1;
}

Once again, I realize this should be easy, but I just can't seem to figure out the code. Any help would be much appreciated.
You just combine the if statements to form one expression:

if(float1 == 3 || float2 == 3){
action1;
}

|| means or && means and so you can combine statements. If they both must equal 3 (not just one) then you would use && instead of ||.

I would pick up a basic Objective-C textbook and skim through it. Will cover a bunch of the basics like this and will be great for future reference.
Vortec4800 is offline   Reply With Quote
Old 05-27-2009, 05:21 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 157
starwarsdevwookie59 is on a distinguished road
Default

good idea, and thank you for your help.
starwarsdevwookie59 is offline   Reply With Quote
Reply

Bookmarks

Tags
action, statements, values

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 342
5 members and 337 guests
givensur, ipodphone, jbro, mer10, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:09 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0