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

View Single Post
Old 04-23-2009, 05:38 AM   #6 (permalink)
tarenar
Registered Member
 
Join Date: Mar 2009
Posts: 10
Default

I've structured my plist as follows

Code:
Array (represents all pictures)
   Array1 (represents picture)
      Dictionary1 (2 coordinates for difference in image)
         Number1 (x1 coordinate)
         Number2 (y1 coordinate)
         Number3 (x2 coordinate)
         Number4 (y2 coordinate)
         Number5 (found variable set to 1 if this difference found)
   ...
   ArrayN 
      Dictionary1 
         Number1 
         Number2 
         Number3 
         Number4 
         Number5
An outer array represents all of my pictures, while the inner array represents an individual picture. Each of the 5 dictionaries in the inner array holds coordinates for differences in the pictures. The found variable is set to 1 when a difference for this image is found.

I detect when the user touches each point with the following code, shortened for brevity:
Code:
//pseudo code for brevity
-(void)touchesEnded:

  get touch location
  for (each dictionary in the picture array) {

   if (player touches one of the points) {
   set the found variable for this point to 1/YES
   }
    
}
In the if statement, when a difference is successfully found, I set the "found" variable in my dictionary to "1" to indicate that I found a difference.

In the simulator everything works fine. But when I load the app onto my phone, and tap a difference point, the screen freezes. The only way to quit is to stop it within Xcode. Using the debugger, I pinpointed the crash to the line of code "[currentDiff setObject:tempBool forKey:@"found"];" below. Specifically the tempBool variable.

Code:
//2 rects always point to 1 difference. if finger in one of the two rects, found a difference
if (((CGRectContainsPoint(leftRect, location)) || CGRectContainsPoint(rightRect, location)) && (found == 0))
{
//now that we've found a difference, update local copy of the picture data and set its found flag to 1(true)
NSNumber *tempFound = [[NSNumber alloc] initWithInt:1];
				
[currentDiff setObject:tempFound forKey:@"found"]; //crashing game on iphone
				
[tempFound release];
[localCopyPic replaceObjectAtIndex:i withObject:currentDiff];

}
Why does this code work in the simulator but not on my phone?
tarenar is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,720
Threads: 89,177
Posts: 380,485
Top Poster: BrianSlick (7,120)
Welcome to our newest member, MINCHEW
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:19 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.