在我的.h文件中,我有这个:
@protocol ScanBookDelegate
- (void)MethodNameToCallBack:(NSArray *)s;
@end
@property (nonatomic, weak) id <ScanBookDelegate> delegate;
在我的.m文件中,我有:
@synthesize delegate;
我收到此错误:
Existing ivar 'delegate' for __weak property 'delegate' must be __weak
如何解决此错误?
当我从JSON结果返回数据时,我返回NSArray *
。
更新
这是我的整个.h文件 -
#import <UIKit/UIKit.h>
@protocol ScanBookDelegate
- (void)MethodNameToCallBack:(NSArray *)s;
@end
@interface jabBookScan : NSObject
<NSURLConnectionDelegate, NSURLConnectionDataDelegate>
{
NSURLConnection *internalConnection;
NSMutableData *container;
id <ScanBookDelegate> delegate;
}
- (id)initWithRequest:(NSURLRequest *)req;
- (void)start;
- (NSMutableData *) lookupBook:(NSString *) isbn;
- (void)fetchedData:(NSData *)responseData;
@property (nonatomic, copy) NSURLRequest *request;
@property (nonatomic, copy) void (^completionBlock)(id obj, NSError *err);
@property (nonatomic, strong) NSDictionary *jsonRootObject;
@property NSMutableData *responseData;
@property NSURL *myURL;
@property (nonatomic, weak) id <ScanBookDelegate> delegate;
@end
答案 0 :(得分:2)
摆脱{}(位于顶部)的id <ScanBookDelegate> delegate;
,它应该可以正常工作。使用属性时无需指定。如果您真的想要,那么您可以声明ivar __weak以便它与您的属性匹配(默认情况下,ivars很强)。