views:

425

answers:

3

I am writing some objective-C code and i can't figure out why this does not work:

buttonRect = CGRectMake(0,0,100.0,100.0);//error:incompatible types in assignment
CGRect newFrame = CGRectInset(buttonRect, -0.2, -0.2);//error:incompatible type for argument 1 of CGRectInset
button.frame = newFrame;

buttonRect is a CGRect defined as an instance variable in my class, and button is a UIButton also defined as an instance variable. Why is this not working? My header file:

//
//  MyViewController.h
//  HelloWorld
//
//  Created by RCIX on 7/10/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface MyViewController : UIViewController {
    UITextField *textField;
    UILabel *label;
    NSString *string;
    UIButton *button;
    CGRect *buttonRect;
}

@property (nonatomic, assign) CGRect *buttonRect;
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *label;
@property (nonatomic, retain) IBOutlet UIButton *button;
@property (nonatomic, retain) NSString *string;

- (IBAction)helloButtonDown:(id)sender;
- (IBAction)helloButtonUp:(id)sender;

@end
A: 

Is buttonRect defined elsewhere or do you need to give it a type when you define it?

Devin Ceartas
Its an instance variable in the class i'm using.
RCIX
how is it defined there? Just so we see all the info.
Devin Ceartas
+1  A: 

Double check buttonRect: sure it's not defined as CGRect.

IlDan
No, it is. I made triple sure of that.
RCIX
+2  A: 

buttonRect is declared as a CGRect * — that is, a pointer to a CGRect. Remove the splat and all will be well.

Chuck
That worked. How could i miss something so simple? *smacks forehead*
RCIX
good catch! easy to overlook, very easy.
Devin Ceartas
I told you ;)
IlDan