我正在製作一個應用程序,將幫助有特定健康狀況的人管理他們的藥物。我創建了一種模式來添加使用核心數據工作並保存新葯物的藥物。'NSInvalidArgumentException',原因:' - [UINavigationController setMed:]:無法識別的選擇發送到實例0x746dda0'
我現在正試圖讓人們在保存後編輯藥物。要做到這一點,我試圖發送藥物的管理對象到「fibromappMedsEditViewController」,並在類的viewDidLoad方法中分配信息。
我不斷收到此錯誤:
'NSInvalidArgumentException', reason: '-[UINavigationController setMed:]: unrecognized selector sent to instance 0x746dda0'
有誰告訴我什麼,我做錯了什麼?
在fibromappMedsListViewController.m相關方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ //selMed declared at top of file as NSManagedObject *selMed;
selMed = [self.meds objectAtIndex:indexPath.row];
NSLog(@"SELECTED MED: %@",[selMed valueForKey:@"name"]);
UIStoryboardSegue *segueString = [NSString stringWithFormat:@"%@",@"editMeds"];
NSLog(@"%@",segueString);
[self performSegueWithIdentifier:@"editMeds" sender:indexPath];
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"%@",segue.destinationViewController);
NSLog(@"%@",[selMed valueForKey:@"name"]);
fibroMappMedsEditViewController *dest = segue.destinationViewController;
dest.med = selMed;
}
的fibroMappMedsEditViewController.h
#import <UIKit/UIKit.h>
@interface fibroMappMedsEditViewController : UITableViewController
- (IBAction)saveChanges:(id)sender;
- (IBAction)deleteBtnPressed:(id)sender;
- (IBAction)dosageChanged:(id)sender;
- (IBAction)maxDosageChanged:(id)sender;
- (IBAction)cancel:(id)sender;
- (IBAction)typeChanged:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *tbName;
@property (weak, nonatomic) IBOutlet UITextField *tbDose;
@property (weak, nonatomic) IBOutlet UITextField *tbMaxDose;
@property (weak, nonatomic) IBOutlet UITextField *tbType;
@property (weak, nonatomic) IBOutlet UIStepper *stepperDose;
@property (weak, nonatomic) IBOutlet UIStepper *stepperMaxDose;
@property (weak, nonatomic) IBOutlet UISegmentedControl *changeMeasure;
@property (strong, nonatomic) NSManagedObject *med;
@end
的fibroMappMedsEditViewController.m - 只是我改變影響的方式,部分控制器負載
#import "fibroMappMedsEditViewController.h"
#import "fibroMappAppDelegate.h"
#import <CoreData/CoreData.h>
@interface fibroMappMedsEditViewController()
@end
@implementation fibroMappMedsEditViewController
@synthesize tbName;
@synthesize tbDose;
@synthesize tbMaxDose;
@synthesize tbType;
@synthesize med;
double dose;
double maxDose;
- (void)viewDidLoad
{
[super viewDidLoad];
tbName.text = [med valueForKey:@"name"];//name is a string in the model
tbDose.text = [med valueForKey:@"dose"];//dose is a double in the model
tbMaxDose.text = [med valueForKey:@"maxDose"];//maxDose is a double in the model
tbType.text = [med valueForKey:@"type"];//type is a string in the model
}
如果您需要查看其他內容,請隨時詢問。
此外,我正在使用這個應用程序的故事板。
這是什麼表現?的NSLog(@ 「%@」,segue.destinationViewController); – rdelmar