我有一個錯誤,我不明白。爲什麼我的代表沒有收到這個選擇器?
我有一個類來幫着打印作業:
//.h
@interface PrintDelegate : NSObject <UIPrintInteractionControllerDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) FFDetailViewController* controller;
@property (strong, nonatomic) NSMutableData* pdf;
@property (assign) int pageCount;
@property (strong, nonatomic) NSArray* fields;
@property (weak, nonatomic) UIPrintInteractionController* printController;
- (id) initWithPageCount:(int)pc forFields:(NSArray*)flds Controller:(FFDetailViewController*)ctlr;
- (int) printFromButton: (UIBarButtonItem*) btn;
- (void) makePDF;
- (void) shift:(PixelShiftDirection)dir pixelCount:(int)amt;
- (void) adjustFields;
- (void) onPrintComplete;
@end
打印完成時我顯示一個警告詢問用戶是否想(再次和打印)調整打印輸出。
//.m
- (void) onPrintComplete
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Printing Complete" message:@"Would you like to adjust the field positions?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Adjust", nil];
[alert show];
}
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString* clickedButton = [alertView buttonTitleAtIndex:buttonIndex];
if ([clickedButton isEqualToString:@"Adjust"])
{
[self adjustFields];
}
}
當我在警報可輕按按鈕,我得到類似的錯誤這樣:
-[__NSArrayM alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance
對象接收不好的選擇總是有一些奇怪的,(我也看到NSCFArrayM和__NSMallocBlock)。選擇器是來自UIAlertViewDelegate協議的一種方法。我不明白爲什麼選擇器被髮送到一些不正確的對象而不是我的PrintDelegae對象。
感謝