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 07-29-2010, 08:39 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
wardyfloyd is on a distinguished road
Default Really simple INT problems.

I have two ints: p1YES and p1NO, and i use them as yes/no to trigger something later in the code, but it isnt working

Code:
p1YES == 0;
p1NO == 0;

-(void)good {
p1YES += 1;
}

-(void) bad {
p1NO += 1;
}

-(void) goodbad {

if (p1YES == 1) {
		
		[goodp1 setTitle:@"Good" forState:UIControlStateNormal];
		[goodp2 setTitle:@"Good" forState:UIControlStateNormal];
				
	}
	
	if (p1YES == 1) {
		
		[badp1 setTitle:@"Bad" forState:UIControlStateNormal];
		[badp2 setTitle:@"Bad" forState:UIControlStateNormal];

	}

}
goodp1, goodp2, badp1, and badp2 are all UIButtons.

What am I doing wrong?
wardyfloyd is offline   Reply With Quote
Old 07-29-2010, 09:03 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Well, there are all sorts of things you could be doing wrong. There is no way to tell what it might be from what you have posted. First of all, it is not clear what the scope of p1NO and p1YES are. Are they instance variables of a single object? Are they static variables belonging to no object at all? Then there is the question of whether or not good and bad are being called once and only once. If they are called twice, then the variable might go up to 2 and thus still fail the (==0) test. You have some simple debugging to do.

By the way, are you aware that you have double equal signs in
Code:
p1YES == 0;
p1NO == 0;
With the double equal signs, these statements are meaningless.
RLScott is offline   Reply With Quote
Old 07-29-2010, 09:06 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
wardyfloyd is on a distinguished road
Default

Ok well i tried changing the code to read

Code:
if (p1YES > 0) {

}
but it still doesnt work
wardyfloyd is offline   Reply With Quote
Old 07-29-2010, 09:14 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
wardyfloyd is on a distinguished road
Default

I defined p1YES and p1NO in my .h
wardyfloyd is offline   Reply With Quote
Old 07-29-2010, 09:19 PM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

You haven't even said what "doesn't work" means. What did you expect to see happen and what did happen instead? And saying that you defined those variables in your .H file says nothing. You still didn't answer my questions. Post all the code if you can't determine what is relevant.
RLScott is offline   Reply With Quote
Old 07-29-2010, 09:23 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
wardyfloyd is on a distinguished road
Default

Ok well, basically, the labels on the buttons dont show up. everything else works fine. posting all the code would be quite alot. i posted everything that uses p1YES and p1NO. that is all they are used for. they are defined in .h and then used for the code I gave you. nothing else.
wardyfloyd is offline   Reply With Quote
Old 07-29-2010, 10:22 PM   #7 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

If you are too lazy to explain your problem sufficiently, then I am too lazy to bother any more with your problem.
RLScott is offline   Reply With Quote
Old 07-29-2010, 10:39 PM   #8 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
wardyfloyd is on a distinguished road
Default

Ok, sorry, no need to be angry or sardonic.
wardyfloyd is offline   Reply With Quote
Reply

Bookmarks

Tags
int, simple

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: 339
16 members and 323 guests
appservice, bignoggins, dermotos, Domele, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, linkmx, mariano_donati, Objective Zero, Paul Slocum, Rudy, Sloshmonster, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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