Monkeyanator
Monkeyanator

Reputation: 1416

Implicit Conversion from Objective-C Pointer to int * is Disallowed With ARC

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

Upvotes: 2

Views: 9816

Answers (3)

gnasher729
gnasher729

Reputation: 52538

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.

Upvotes: -5

Junfeng Li
Junfeng Li

Reputation: 67

I think you should change

#import "DMGSecondaryStatViewController.h"

to

@class DMGSecondaryStatViewController;

Upvotes: 5

Rob Napier
Rob Napier

Reputation: 299355

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.

Upvotes: 5

Related Questions