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 Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-16-2011, 03:20 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
prasanthkumaar is on a distinguished road
Exclamation IBActions in "if" statements

I want to put the IBAction in the if statements like this :

-(IBAction)example {

example

}


if ((IBAction)example) {

Something


}


So basically if that button is pressed it should "Something" should happen. If it isn't pressed "Something" should not happen
prasanthkumaar is offline   Reply With Quote
Old 03-16-2011, 03:39 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 29
Zincous is on a distinguished road
Default

You can't put an IBAction inside an if statement like that. You'll have to do something like:

Code:
-(IBAction)example {

example = true;

if (example = true) {

do this;

}

}
So whatever you do inside the example IBAction, then gets checked by the if statement to determine if it should enter or not.
__________________
Twitter: @Zincous, @Zincous_Apps
Zincous is offline   Reply With Quote
Old 03-17-2011, 05:21 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
prasanthkumaar is on a distinguished road
Exclamation

but it gives me an error. saying that the example is undeclared


-(IBAction)example {

example = true; //Example undeclared//

if (example = true) {

do this;

}

}
prasanthkumaar is offline   Reply With Quote
Old 03-17-2011, 05:26 PM   #4 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 29
Zincous is on a distinguished road
Default

Quote:
Originally Posted by prasanthkumaar View Post
but it gives me an error. saying that the example is undeclared


-(IBAction)example {

example = true; //Example undeclared//

if (example = true) {

do this;

}

}
Yeah it was just an example, a place holder for where you'd need to put your actual code of what you want to happen.

I don't know what you have declared in your header file. But it could be any number of things you can put in there.

myButton.enabled = TRUE;
myLabel.hidden = TRUE;

(You'd have to declare 'myButton' or 'myLabel' for those to work too)
__________________
Twitter: @Zincous, @Zincous_Apps
Zincous is offline   Reply With Quote
Old 03-17-2011, 09:06 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
prasanthkumaar is on a distinguished road
Default

can u pass me your email address so that i can send you my xcode file
prasanthkumaar is offline   Reply With Quote
Old 03-31-2011, 01:07 PM   #6 (permalink)
Registered Member
 
mobileben's Avatar
 
Join Date: Jul 2009
Location: Zgrunturos
Posts: 161
mobileben is on a distinguished road
Default

IBAction is defined as a void.

When you see:

-(IBAction)myButtonWasPressedid)sender;

This translates to

-(void)myButtonWasPressedid)sender;

IB uses IBAction to understand that you can make a connection.

As it was already pointed at, you don't want to put an IBAction in an if.

Are you trying to recursively call your function? Is that your intent?
__________________
Have a Poketastic time with QuitIt!
Arcade Basketball at it's best! Hoops Madness!
VS action on the iPad with Hoops Madness VS!
Sweet trailer here!
mobileben is offline   Reply With Quote
Reply

Bookmarks

Tags
help me, ibaction, if statement

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: 423
5 members and 418 guests
chemistry, hussain1982, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

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