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.h
Cannot find protocol declaration for 'OverlayViewControllerDelegate'; did you mean 'UISplitViewControllerDelegate'?
。
MyViewController.h
#import <UIKit/UIKit.h>
#import "OverlayViewController.h"
@interface MyViewController : UIViewController <UIImagePickerControllerDelegate, OverlayViewControllerDelegate>
@end