1
votes

I have an class DMGStatController which has a delegate of type DMGSecondaryStatViewController. I write

DMGStatController *controller = [[DMGStatController alloc] init]; 
controller.delegate = self;

It is this second line of code that is giving me the error "Implicit Conversion from Objective-C Pointer to int * is Disallowed With ARC". I don't know what the compiler is talking about... DMGStatController's property delegate is of type DMGSecondaryStatViewController, not int *. Any help would be much appreciated.

Also, here is where I declare the delegate.

#import <UIKit/UIKit.h>
#import "DMGSecondaryStatViewController.h"


@interface DMGStatDescriptionViewController : UIViewController{

}

@property(nonatomic , retain) DMGSecondaryStatViewController *delegate; 
@property(nonatomic , retain) NSString *finalStatChosen; 

@end
3
Which type is the delegate property of DMGStatController ?ldiqual
I think you need to post the declaration of the delegate property.pmdj

3 Answers

4
votes

Make sure to #import "DMGStatController.h", and that the header includes a @class DMGSecondaryStatController. You likely have a warning about the fact that it doesn't know what DMGSecondaryStatController is and that it's defaulting to int. Make sure that there are no warnings in your ObjC code. Most ObjC "warnings" are in fact errors.

4
votes

I think you should change

#import "DMGSecondaryStatViewController.h"

to

@class DMGSecondaryStatViewController;

-3
votes

The lesson to learn: The compiler is right. The mental attitude "I don't know what the compiler is talking about" prevents you from finding the solution. You insist on your code being right, so you can't find the bug. The right attitude is "I made a mistake. What mistake did I make?"

If you turn on a few more warnings, you'll probably find that the compiler couldn't find a delegate method, therefore made some assumptions about what the parameters of the delegate method would be, and then complained because the conversion wasn't allowed.