Guest User

Untitled

a guest
May 2nd, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. sometimes crash EXC_BAD_ACCESS with no message (set NSZombieEnabled)
  2. int currPower = [[powers objectAtIndex:i] intValue];
  3. int prevPower = [[powers objectAtIndex:i - 1] intValue];
  4.  
  5. powers = [[NSMutableArray alloc] initWithCapacity:POWER_ARRAY_SIZE];
  6.  
  7. - (void)dealloc {
  8. [powers release];
  9. [super dealloc];
  10. }
  11.  
  12. - (void)drawRect:(CGRect)rect
  13. {
  14. ...//Do Something
  15. ...//Check "endindex" and "startindex" not to exceed boundary
  16.  
  17. for (int i = endindex; i > startindex; i-=1)
  18. {
  19.  
  20. int currPower = [[powers objectAtIndex:i] intValue];
  21. int prevPower = [[powers objectAtIndex:i - 1] intValue];
  22.  
  23. ...//Doing something
  24.  
  25. }
  26. }
  27.  
  28. - (void)setPower:(int)p
  29. {
  30.  
  31. [powers addObject:[NSNumber numberWithInt:p]];
  32.  
  33. while ([powers count] > POWER_ARRAY_SIZE){
  34. [powers removeObjectAtIndex:0];
  35. }
  36. }
  37.  
  38. int power[ARRAYSIZE];
Advertisement
Add Comment
Please, Sign In to add comment