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 Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 04-02-2010, 12:13 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 5
rabbigarfinkel1 is on a distinguished road
Default Why is my IBAction begin triggered twice?

Hello,

I am trying to write a simple program that asks users yes/no questions and, based on those answers, tells them where they stand on the political spectrum.

I have a variable in my code called "questionnumber." My thought was that every time the user clicked the "nextbutton" in my IB interface, I would increase the "questionnumber" variable by 1 and thus present a new question.

This works for questions 1 and 2. But then it starts skipping every other question. Can someone tell me why? I'm stumped! The code appears below: (My IB interface buttons are keyed for "touch up inside" in case that makes a difference.)

#import "MainView.h"
#import <Foundation/Foundation.h>

@implementation MainView
@synthesize Question;
@synthesize mispar;


int conservative = 0;
int liberal = 0;
int questionnumber = 0;



- (IBAction)agreebutton: (id) sender {

++liberal;

}

- (IBAction)disagreebuttonid) sender {

++conservative;

}



- (IBAction)nextbuttonid) sender {

++questionnumber;

switch (questionnumber) {


case 1:

Question.text = @"Congress should pass a law that would ban Americans from earning more than one hundred million dollars in any given year.";
break;

case 2:

Question.text = @"It is not fair to admit people to a university or employ them on the basis of merit alone. Factors such as race, gender, class, and sexual orientation must also be considered.";
break;


case 3:

Question.text = @"There are two Americas - one for the rich and one for the poor.";
break;

case 4:

Question.text = @"Top quality health care should be free for all.";
break;



default:
break;
}
}




@end
rabbigarfinkel1 is offline   Reply With Quote
Reply

Bookmarks

Tags
interface builder, variables

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: 375
8 members and 367 guests
comicool, husthlj, illogical, LegionMD, LunarMoon, mer10, Murphy, padsoftware
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,677
Threads: 94,127
Posts: 402,916
Top Poster: BrianSlick (7,990)
Welcome to our newest member, husthlj
Powered by vBadvanced CMPS v3.1.0

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