わからないエラーが発生しました。
印刷ジョブを支援するクラスがあります。
//.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オブジェクトではなく、誤ったオブジェクトにセレクターが送信される理由がわかりません。
ありがとう