xcode错误:masterViewController没有声明选择器的可见@接口

3

我遇到了一个看起来相当普遍的问题,但我无法确定我的代码具体出了什么问题。

我搜遍了stackoverflow并阅读了至少十几篇类似于我问题的帖子,但我无法弄清楚我的问题。

基本上,我正在尝试将NSMutableDictionary从模态视图传递到主视图。下面是代码:

QuoteMasterViewController.h:

    @class QuoteModalViewController;
    @interface QuoteMasterViewController : UITableViewController
    @end

QuoteMasterViewController.m:

#import "QuoteMasterViewController.h"
#import "QuoteModalViewController.h"
#import "QuoteDetailViewController.h"

@interface QuoteMasterViewController () {
    NSMutableArray *_objects;
    }
@end

@implementation QuoteMasterViewController

//after the ViewDidLoad method...

-(void)addQuotationWithDictionary: (NSMutableDictionary *)myDictionary {

     [self insertNewObject:myDictionary];
     [self dismissModalViewControllerAnimated:YES];
 }

QuoteModalViewController.h:

 #import <UIKit/UIKit.h>

 @class QuoteMasterViewController;

 @interface QuoteModalViewController : UIViewController <UITextFieldDelegate>

 @property (nonatomic, weak) QuoteMasterViewController *masterView;
 @property (strong, nonatomic) IBOutlet UITextField *sourceQuoted;
 @property (strong, nonatomic) IBOutlet UITextField *quoteQuoted;
 - (IBAction)saveButtonPressed:(id)sender;
 - (IBAction)cancelButtonPressed:(id)sender;

 @end

QuoteModalViewController.m:

#import "QuoteModalViewController.h"
#import "QuoteMasterViewController.h"

@interface QuoteModalViewController ()

@end

@implementation QuoteModalViewController

@synthesize sourceQuoted;
@synthesize quoteQuoted;
@synthesize masterView;


//After ViewDidLoad
- (IBAction)saveButtonPressed:(id)sender {
    if (![sourceQuoted.text isEqualToString:@""] && ![quoteQuoted.text isEqualToString:@""]) {
        NSString *sourceString = sourceQuoted.text;
        NSString *quoteString = quoteQuoted.text;
        NSMutableDictionary *quotesDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys: sourceString, @"Source", quoteString, @"Quote", nil];
        [masterView addQuotationWithDictionary:quotesDict]; //Error occurs here
        NSLog(@"%@", quotesDict);
    }
}

非常感谢您提前提供的任何帮助!

1个回答

7

您没有在头文件中声明方法。请添加。

-(void)addQuotationWithDictionary: (NSMutableDictionary *)myDictionary;

在QuoteMasterViewController.h文件的@interface QuoteMasterViewController@end之间添加内容。

2
非常感谢,这正是我所需要的。哥们儿,我真的喜欢这个社区。 - hi_Matt

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接