views:

48

answers:

3

I have a compiler error and I just can't work out what is wrong. I am new to this so stuggling to decipher the error.

In my .h I have...

@interface LongViewController : UIViewController {

    IBOutlet UIImageView *loadImageInto;
    IBOutlet UIImageView *loadedInto;
}

-(void)fadeIt:(UIImageView*)imgNamed;

And in my .m...

-(void)fadeIt:(UIImageView*)imgNamed
{
    if(longSize1.alpha == 0.0){
        loadImageInto = longSize1;
        loadedInto = longSize2;
    }
    if(longSize2.alpha == 0.0){
        loadImageInto = longSize2;
        loadedInto = longSize1;
    }

    loadImageInto.image = [UIImage imageNamed:imgNamed];
}

The warning I am getting is on the last line and is:

warning passing argument 1 of 'imageNamed' from distinct objective-c type

I think it is saying that the type is wrong but I can't seem to sort it out. It is probably saying that the code is running fine and the images are loaded as expected.

Any help would be much appreciated!

A: 

Could you drop in a few NSLogs please? For all the variables at play.

JoePasq
and could you give us the error also?
JoePasq
+1  A: 

UIImage imageNamed: takes a NSString * which is the name of the image to load. It sounds like your imgNamed variable is not the correct type (not a NSString *).

David Kanarek
A: 

you can try

loadImageInto = imgNamed ;
Nnp