问题
My Xcode app is getting the following exception error message.
-[UINavigationController setDeals:]: unrecognized selector sent to instance 0x8338d40
The exception is being thrown in the following context in the prepareForSegue:
method, likely with the destination
item. The key line where the exception is thrown is marked with this comment. //**********exception
BSViewController.h
#import <UIKit/UIKit.h>
@class BSData;
@interface BSViewController : UIViewController <UITextViewDelegate, UITextFieldDelegate>
{
}
@property (nonatomic) NSInteger iboard;
@property (nonatomic, strong) NSArray *deals;
@property (nonatomic, strong) BSData *data;
@end
BSViewController.m
#import "BSViewController.h"
#import "BSdealViewController.h"
#import "BSData.h"
@interface BSViewController ()
@end
@implementation BSViewController
@synthesize iboard, deals;
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// The identifier here must match the one you assigned to the segue in the storyboard.
NSLog(@"identifier=%@ destination=%@", segue.identifier, segue.destinationViewController);
if ([segue.identifier isEqualToString:@"UrlToDeal"]) {
BSData *data;
BSdealViewController *destination = segue.destinationViewController;
data = [[BSData alloc] initWithNumber:self.iboard array:self.deals];
NSLog(@"segue iboard:%d", self.iboard);
NSLog(@"segue deals:%@", self.deals);
destination.deals = self.deals; //**********exception
destination.iboard = self.iboard;
}
}
@end
BSData.h
#import <Foundation/Foundation.h>
@interface BSData : NSObject
@property (nonatomic) NSInteger iboard;
@property (nonatomic, copy) NSArray * deals;
- (id)initWithNumber:(NSInteger)iboard array:(NSArray *)deals;
@end
BSData.m
#import "BSData.h"
@implementation BSData
- (id)initWithNumber:(NSInteger)iboard array:(NSArray *)deals
{
self = [super init];
if (self) {
NSLog(@"self initWithNumber");
_iboard = iboard;
_deals = deals;
return self;
}
return nil;
}
@end
BSdealViewController.h
#import <UIKit/UIKit.h>
#import <Accelerate/Accelerate.h>
#include "BSParam.h"
@class BSData;
@interface BSdealViewController : UIViewController <UINavigationControllerDelegate>
@property (nonatomic, strong) BSData *data;
@property (nonatomic) NSInteger iboard;
@property (nonatomic, weak) NSArray *deals;
@end
BSdealViewController.m
#import "BSData.h"
#import "BSdealViewController.h"
#import "BSViewController.h"
@interface BSdealViewController ()
@end
来源:https://stackoverflow.com/questions/15427108/unrecognized-selector-sent-to-instance-uinavigationcontroller