3

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.

gniourf_gniourf
  • 44,650
  • 9
  • 93
  • 104
luke88
  • 958
  • 19
  • 40

2 Answers2

13

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

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
  • The guide I am using is wrong. And because is the first time that I programming to ios I had never heard CGRectMake. Thanks and sorry for the stupid question! – luke88 Dec 28 '12 at 15:17
0

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

 UILabel *testLabel = [[UILabel alloc] initWithFrame: CGRectMake(30.0f,100.0f,250.0f,40.0f)];
Nitin Alabur
  • 5,812
  • 1
  • 34
  • 52
  • The implicit cast should do the job, it's the same. – Ramy Al Zuhouri Dec 27 '12 at 17:13
  • 3
    People, downvotes are for answers that are unhelpful. This answer provides an example that fixes the problem. How is that unhelpful? True, it might have been *more* helpful if it included an explanation, but three downvotes? Seriously? – jlehr Dec 27 '12 at 17:32
  • It's not a problem fix (actually it fix a problem but there should be some explanations too). And it's better for a person who wrote it just delete his answer and keep a page clear. – anatoliy_v Dec 27 '12 at 17:58
  • @jlehr: I didn't downvote, but the most obvious change this answer makes from the code in the question is changing the integer literals to laboriously specified floating point literals, which is *completely and utterly ineffectual*. The actual problem is not addressed, but vaguely alluded to with "in addition to my comment". So the overall impression that this answer creates — that you need to put decimal points and `f`s after your floating point literals — is deceptive. I definitely see why it would be considered not helpful. – Chuck Dec 28 '12 at 01:07
  • Thanks @Chuck . The actual problem was referred to in the comments (of the question). my assumption was that UILabel categories using custom structs were being used. As a practice, I prefer to write down the correct line of code, with what I consider is the right way to write. Agreed that my answer makes it look like I was emphasizing on ".0f" (I'll try to be clear next time), but, an unhelfpul answer is one that doesn't solve the problem. (my answer does!) – Nitin Alabur Dec 29 '12 at 01:38