[英]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.