calling the protocol methods in objective c
i have used the following protocol in the yyyy.h file of a class
@protocol FGalleryViewControllerDelegate
@require开发者_如何转开发d
- (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,,
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?
if you want self to call those then set the @property of this delegate object. and then use it it works.
精彩评论