错误:分配中的类型不兼容

RCI*_*CIX 2 cocoa compiler-errors objective-c

我正在写一些客观的C代码,我无法弄清楚为什么这不起作用:

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;
Run Code Online (Sandbox Code Playgroud)

buttonRect是一个CGRect,在我的类中被定义为一个实例变量,而button是一个UIButton,也被定义为一个实例变量.为什么这不起作用?我的头文件:

//
//  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
Run Code Online (Sandbox Code Playgroud)

Chu*_*uck 8

buttonRect声明为CGRect *- 即指向 CGRect 的指针.去掉啪啪声,一切都会好的.