Damian
Damian

Reputation: 5561

Compiler errors after upgrading to XCode 4

I've upgraded xcode and ios sdk to the latest version (xcode 4.0 / ios sdk 4.3) and now I'm getting compiler errors on a project that was building before.

This is the code:

- (void)layoutSubviews
{
    int w = 320;
    int h = 480;

    float ver = [[[UIDevice currentDevice] systemVersion] floatValue];
    // You can't detect screen resolutions in pre 3.2 devices, but they are all 320x480
    if (ver >= 3.2f){
        UIScreen* mainscr = [UIScreen mainScreen];
        w = mainscr.currentMode.size.width;
        h = mainscr.currentMode.size.height;    

        if( ver >= 4.0f ) {
            float scaleFactor = mainscr.scale;

            // this will scale the OpenGLView for retina screens
            self.contentScaleFactor = scaleFactor;
            CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
            eaglLayer.contentsScale=scaleFactor; //new line            
        }
    }

    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer *)self.layer];
    setOpenGLSize(w,h);
    [self drawView:nil];
}

And these are the errors:

error: property 'scale' not found on object of type 'UIScreen *' [2]
error: property 'contentScaleFactor' not found on object of type 'EAGLView *' [2]
error: property 'contentsScale' not found on object of type 'CAEAGLLayer *' [2]

I have Base SDK setted to iOS 4.3 and deployment target to iOS 3.0 If i set deplyment target to 4.3, the error dissapear, but I want the app to run on 3.0 and above.

What's wrong with the code or the project?

Upvotes: 0

Views: 812

Answers (1)

user189804
user189804

Reputation:

"I have Base SDK setted to iOS 4.3 and deployment target to iOS 3.0"

So it is warning you that the properties scale, contentScaleFactor and contentsScale were introduced in 4.0 and you can't use them in 3.x.

If you really want to deploy to 3.x (and everything I've seen says it is of questionable worth to make your app support it, especially since the unification of iOS post-iPad2) then you have to work around those properties not being there.

Upvotes: 1

Related Questions