CGRect problem.

Discussion in 'iOS Programming' started by larswik, Jun 11, 2014.

  1. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    I am getting this error message and it makes no sense. I am giving it what it needs?

    When I add a UIImageView to the screen I add it as a used object to an NSMutableArray. Then I check to see if the objects collide with this for loop using fast enumeration. If there is a UIView frame collision I am creating a explosion UIImageView Animation. I am simply using the frame of the object on the view for the origin and size for the explosion animation. I should not be getting this error?

    I also tried to typecast like so.
    Code:
    CGRect *poofRect = (CGRect) userObject.frame;
    
    The code
    Code:
    for (UIImageView *userObject in userDefenceObjects) {
                if (CGRectIntersectsRect(cannonBallView1.frame, userObject.frame)) {
                    if (!col) {
                        col = [[Collisions alloc]init];
                    }
                    BOOL collision = [col checkAlphaAnimationCollision:cannonBallView1 withObj:userObject];
                    
                    if (collision) {
                        [hitAudio play];
                        gameRunning = NO;
                        CGRect *poofRect = userObject.frame;
                        [userObject removeFromSuperview];
                        [cannonBallView1 removeFromSuperview];
                        NSLog(@"BANG");
                        [self performSelector:@selector(newGame) withObject:nil afterDelay:2];
                    }
    
                }
            }
    
    
     
  2. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    CGRect is not an object, it's a C struct.

    Look at the signature:

    Code:
    - (CGRect)frame;
    So...

    Code:
    CGRect r = userObject.frame;
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  4. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #4
    O jezz, I knew that. It was a simple mistake. Time to step away from the computer and go for a walk.

    Thanks.

    -Lars
     

Share This Page