2013-02-21 76 views
0

PhotoPicker sample code uses an overlay view。以下是我在我的应用程序中使用的PhotoPicker的一些相关代码,但我想使用ARC,并且PhotoPicker不使用ARC。我想我已经设法解决PhotoPicker和ARC之间的其他冲突,但不是这一个。Xcode ARC与overlayviewcontroller冲突

当我在OverlayViewController.h中使用id <OverlayViewControllerDelegate> delegate;下面的行时,我得到错误Existing ivar 'delegate' for property 'delegate' with assign attribute must be __unsafe_unretained

OverlayViewController.h

#import <UIKit/UIKit.h> 
#import <AudioToolbox/AudioServices.h> 

@protocol OverlayViewControllerDelegate; 

@interface OverlayViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> 
{ 
    id <OverlayViewControllerDelegate> delegate; // **THIS IS THE KEY LINE** 
}  

@property (nonatomic, assign) id <OverlayViewControllerDelegate> delegate; 
@property (nonatomic, retain) UIImagePickerController *imagePickerController; 

- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType; 

@end 

@protocol OverlayViewControllerDelegate 
- (void)didTakePicture:(UIImage *)picture; 
- (void)didFinishWithCamera; 
@end 

But when I follow the advise here,并且或者注释掉该行或前置一个符合__unsafe_unretained,我得到的问题MyViewController.hCannot find protocol declaration for 'OverlayViewControllerDelegate'; did you mean 'UISplitViewControllerDelegate'?

MyViewController.h

#import <UIKit/UIKit.h> 

#import "OverlayViewController.h" 

@interface MyViewController : UIViewController <UIImagePickerControllerDelegate, OverlayViewControllerDelegate> 
@end 

回答

0

有我的问题的错误。很抱歉。 在实际代码中,#import "OverlayViewController.h已被省略。

MyViewController.h 

#import <UIKit/UIKit.h> 

#import "OverlayViewController.h"