【发布时间】:2014-07-01 02:44:19
【问题描述】:
得到一个 NSException 错误。环顾四周,这可能是我调用该方法的方式,但无法对其进行故障排除,我是初学者,非常感谢一个好的解释。
这是我的 AddListingViewController.h
#import <UIKit/UIKit.h>
#import "ListingTableViewController.h"
#import "ListingManager.h"
@interface AddListingViewController : UIViewController
@property (nonatomic) ListingTableViewController *manager;
@property (nonatomic) ListingManager *add;
@end
这是我的 AddListingViewController.m
#import "AddListingViewController.h"
@interface AddListingViewController ()
@property (weak, nonatomic) IBOutlet UITextField *title;
@property (weak, nonatomic) IBOutlet UITextView *desc;
@property (weak, nonatomic) IBOutlet UITextField *price;
@end
@implementation AddListingViewController
@synthesize manager = _manager;
@synthesize add = _add;
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.manager = [[ListingTableViewController alloc] init];
self.add = [[ListingManager alloc] init];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//cancel posting on tap
- (IBAction)cancelListing:(UIBarButtonItem *)sender {
NSLog(@"cancel tapped thpugh");
[self dismissViewControllerAnimated:YES completion:nil];
}
//add item on tap
- (IBAction)addListing:(UIBarButtonItem *)sender {
NSLog(@"Add button tapped");
self.add.listingTitle = self.title.text;
self.add.listingDescription = self.desc.text;
self.add.listingPrice = self.price.text;
[self.manager.listings addObject:self.add];
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
我得到的错误(我确定它说得很清楚,但我不知道如何解决它)
2014-06-30 21:37:44.825 Wildcat Exchange[1981:180450] Add button tapped
2014-06-30 21:37:44.827 Wildcat Exchange[1981:180450] -[UITextInputTraits text]: unrecognized selector sent to instance 0xc193e90
2014-06-30 21:37:44.831 Wildcat Exchange[1981:180450] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextInputTraits text]: unrecognized selector sent to instance 0xc193e90'
【问题讨论】:
-
添加一个objective-c异常断点,看看你的代码的哪一行触发了异常。最好的猜测是您的 XIB 文件中有错误连接。
标签: objective-c ios7 nsexception