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 10-25-2010, 07:12 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default Trouble with some code, LOGICAL

Hi everyone, i am just having some trouble with some code:

Code:
- (void) BG {

	BOOL greenBGAp = [[NSUserDefaults standardUserDefaults] boolForKey:@"greenBGAp"];
	BOOL blueBGAp = [[NSUserDefaults standardUserDefaults] boolForKey:@"blueBGAp"];
	
	if (greenBGAp == TRUE) {
		BG.image = [UIImage imageNamed:@"greenBG.png"];
	} else {
		BG.image = [UIImage imageNamed:@"BG.jpg"];
	}
	
	if (blueBGAp == TRUE) {
		BG.image = [UIImage imageNamed:@"blueBG.png"];
	} else {
		BG.image = [UIImage imageNamed:@"BG.jpg"];
	}
}
it doesn't work, and i know why but i can't seem to fix it.

problem 1: with both of those if statements the greenBG never shows up because if blueBGAp is 0 and greenBGAp is 1 it is BG.jpg because of the second if statement.

problem 2: obviesly if one of the BOOLs is TRUE i want the other BOOLS FALSE. but as you can see if the other BOOLs are FALSE it changes to BG.jpg.

thank you to all the smart people who help solve this problem!

by the way i am going to have a whole bunch more colors but i don't want to move on untill i get this problem solved.
sumosumo84 is offline   Reply With Quote
Old 10-25-2010, 07:39 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 327
thomashw is on a distinguished road
Default

Code:
- (void) BG {

	BOOL greenBGAp = [[NSUserDefaults standardUserDefaults] boolForKey:@"greenBGAp"];
	BOOL blueBGAp = [[NSUserDefaults standardUserDefaults] boolForKey:@"blueBGAp"];
	
	if (greenBGAp == TRUE)
		BG.image = [UIImage imageNamed:@"greenBG.png"];
	else if (blueBGAp == TRUE)
		BG.image = [UIImage imageNamed:@"blueBG.png"];
	else
		BG.image = [UIImage imageNamed:@"BG.jpg"];
}
thomashw is offline   Reply With Quote
Old 10-25-2010, 07:43 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 139
sumosumo84 is on a distinguished road
Default

Thanks!
sumosumo84 is offline   Reply With Quote
Reply

Bookmarks

Tags
code, colors, error, logical error, trouble

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: 327
15 members and 312 guests
7twenty7, chiataytuday, condor304, Creativ, Desert Diva, Domele, dreamdash3, laureix68, LEARN2MAKE, mistergreen2011, mottdog, palme2elie, Paul Slocum, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,660
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, laureix68
Powered by vBadvanced CMPS v3.1.0

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