iOS Error with GCRectMake - Sending 'int' to parameter of incompatible type 'CGRect' (aka 'struct CGRect')

StackOverflow https://stackoverflow.com/questions/14058342

Question

I'm new in the iOS programming.

I am following a guide, a book precisely on iOS in Italian. For the first application, I have to modify ViewController.m like this:

#import "ViewController.h"

@implementation ViewController

- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
    // Release Any chached data, images, etc that aren't in use.
}    

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)datiDettaglioChiudi:(datiDettaglio *)controller{
    //altre operazioni possibii dopo la dismissModal
    NSLog(@"... di ritorno dal DismissModal...");
    [controller dismissViewControllerAnimated:YES completion:nil];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"dettaglio"]){
        datiDettaglio *mioController1 = segue.destinationViewController;
        [mioController1 setDelegate:self];
        //aggiunta di una UILabel - qui è possibile personalizzare la propria vista     direttamente da codice
        UILabel *testLabel = [[UILabel alloc] initWithFrame: GCRectMake(30,100,250,40)];
        [testLabel setText:@"Etichetta di test"];
        [testLabel setBackgroundColor:[UIColor greenColor]];
        [testLabel setTextColor:[UIColor blackColor]];
        [mioController1.view addSubview:testLabel];

    }
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}


@end

The problem is here:

UILabel *testLabel = [[UILabel alloc] initWithFrame: GCRectMake(30,100,250,40)];

On the GCRectMake: I've one warning and one errors:

WARNING Implicit declaration of function 'GCRectMake' is invalid in C99
ERROR   Sending 'int' to parameter of incompatible type 'CGRect' (aka 'struct CGRect')

I really can not understand what is wrong.

Was it helpful?

Solution

It's CGRectMake, not GCRectMake. The CG stands for Core Graphics.

OTHER TIPS

This (in addition to my comment) should fix the error

 UILabel *testLabel = [[UILabel alloc] initWithFrame: CGRectMake(30.0f,100.0f,250.0f,40.0f)];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top