[英]calling the protocol methods in objective c
i have used the following protocol in the yyyy.h file of a class 我在类的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
and i am calling these methods using the delegate object 我正在使用委托对象调用这些方法
NSObject < FGalleryViewControllerDelegate> *_photoSource;
in some other class not in yyy.m,, 在yyy.m以外的其他班级中,
now i tried to call these methods in the same class yyy.m,,i used the same delegate object to call the methods but its crashed ,,should i use self to call those? 现在我试图在同一个类yyy.m中调用这些方法,我使用相同的委托对象来调用这些方法,但是崩溃了,我应该使用self来调用那些方法吗?
if you want self to call those then set the @property of this delegate object. 如果要self调用这些对象,则设置此委托对象的@property。 and then use it it works.
然后使用它就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.