The following “Old” code loaded into XCode 4.2 will work.
But if I start a “new project” and “CUT AND PASTE” the code, I get ERROR: Cast of ‘int’ to ‘UILabel*’ is disallowed with ARC
I assume there is a setting in the “Build settings” that I need to set… what do I do?
Thanks…
(and yes I purposely want to do this, too much old code to convert! )
int mice[10];
for (int z=0; z<10; z++) {
UILabel *b = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
mice[z] = (int)b;
}
for (int zz=0; zz<10; zz++) {
//Old project loaded into XCode 4.2 will work fine with this
UILabel *c = (UILabel*) mice[zz];// New project: fails <---------- Cast of 'int' to 'UILabel*' is disallowed with ARC
[self.view addSubview:c];
}
You avoid doing such casting as it has an undefined behavior. Create an array of
UILabels instead.