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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 12-20-2008, 07:39 AM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 30
Default Array Problem, Takes Two Taps To Change...

Ok, I'll try to explain it as best I can.
I have a table, in each cell there is an image view.
There are two images.
0.png is an empty square.
1.png is a square with a cross in it.
I have an array that tells what each cell is currently set to.
@"0.png" if it's "In Progress" or @"1.png" if it's "Completed".
When I click a row in the table, I want it to change.
When I first add a row, it works fine, but when I re-launch the app, it won't change!
I had an if to check if it was @"0.png" and then an else if to check if it was @"1.png" but for some reason, I had to put in an else to automatically set it to 0.png.
I checked the NSLog and even though it says the object is 0.png, it won't set it to 1.png, so it automatically gets set back to 0.png and then I have to tap AGAIN to make it 1.png.
While it isn't an app breaker, it is still annoying and makes it seem... buggy.
Can anyone tell me whats going on?
Here's the code.

Clicking on the row:
Code:
   1.
      - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   2.
              NSLog(@"%@", [comArray objectAtIndex:indexPath.row]);
   3.
              if([comArray objectAtIndex:indexPath.row] == @"0.png"){
   4.
                      NSLog(@"Object is in progress, switching to complete.");
   5.
                      [comArray replaceObjectAtIndex:indexPath.row withObject:@"1.png"];
   6.
              } else if ([comArray objectAtIndex:indexPath.row] == @"1.png") {
   7.
                      NSLog(@"Object is complete, switching to in progress.");
   8.
                      [comArray replaceObjectAtIndex:indexPath.row withObject:@"0.png"];
   9.
              } else {
  10.
                      NSLog(@"Error: Making in progress.");
  11.
                      [comArray replaceObjectAtIndex:indexPath.row withObject:@"0.png"];
  12.
              }
  13.
              tblView.reloadData;
  14.
      }
Making the array:
Code:
comCheckArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"comArray"];
	if(comCheckArray == nil){
		comArray = [[NSMutableArray arrayWithObjects:@"0.png", nil] retain];
		[[NSUserDefaults standardUserDefaults] setObject:comArray forKey:@"comArray"];
		[[NSUserDefaults standardUserDefaults] synchronize];
	} else {
		comArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"comArray"];
	}
	[comCheckArray release];
Adding to the array:
Code:
[comArray addObject:@"0.png"];
tblView.reloadData;
Can you see anything wrong with this code?
Please help :'[
xspyk is offline   Reply With Quote
Old 12-20-2008, 08:09 AM   #2 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 30
Default

Yay, I eventually got this working by implementing "isEqualToString:".
xspyk is offline   Reply With Quote
Reply

Bookmarks

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: 350
20 members and 330 guests
ADY, Dani77, Duncan C, e2applets, Grinarn, HemiMG, Herbie, JasonR, keeshux, linkmx, macquitzon216, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, sly24, Touchmint, twerner, zulfishah
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,881
Threads: 89,228
Posts: 380,760
Top Poster: BrianSlick (7,129)
Welcome to our newest member, macquitzon216
Powered by vBadvanced CMPS v3.1.0

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