[英]calling the protocol methods in objective c
我在类的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来调用那些方法吗?
如果要self调用这些对象,则设置此委托对象的@property。 然后使用它就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.