【发布时间】:2011-09-17 08:44:16
【问题描述】:
我在类的 yyyy.h 文件中使用了以下协议
@protocol FGalleryViewControllerDelegate
@required
- (int)numberOfPhotosForPhotoGallery:(FGalleryViewController*)gallery;
- (FGalleryPhotoSourceType)photoGallery:(FGalleryViewController*)gallery sourceTypeForPhotoAtIndex:(NSUInteger)index;
@optional
- (NSString*)photoGallery:(FGalleryViewController*)gallery captionForPhotoAtIndex:(NSUInteger)index;
// the photosource must implement one of these methods depending on which FGalleryPhotoSourceType is specified
- (NSString*)photoGallery:(FGalleryViewController*)gallery filePathForPhotoSize:(FGalleryPhotoSize)size atIndex:(NSUInteger)index;
- (NSString*)photoGallery:(FGalleryViewController*)gallery urlForPhotoSize:(FGalleryPhotoSize)size atIndex:(NSUInteger)index;
@end
我正在使用委托对象调用这些方法
NSObject < FGalleryViewControllerDelegate> *_photoSource;
在其他一些不在 yyy.m 中的类中,,
现在我尝试在同一个类 yyy.m 中调用这些方法,我使用相同的委托对象来调用这些方法,但是它崩溃了,我应该使用 self 来调用这些方法吗?
【问题讨论】:
-
你在哪里调用这个方法尝试使用这个 object.delegate = self;或者无论如何
-
创建此委托的属性
-
是的,我已经有了它,就像这样 @property (nonatomic,assign) NSObject
*_photoSource;
标签: iphone objective-c xcode ios4 protocols