“unrecognized selector sent to instance” UINavigationController

邮差的信 提交于 2019-12-12 17:38:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!