xcode 错误:masterViewController 没有可见的@interface 声明了选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13131272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xcode error: No visible @interface for masterViewController declares the selector
提问by hi_Matt
I am having what seems to be a fairly common problem but I cannot figure out what is wrong with my code specifically.
我遇到了一个似乎相当普遍的问题,但我无法具体弄清楚我的代码有什么问题。
I have scoured stackoverflow and read at least a dozen posts that are similar to mine, but I cannot figure out my personal problem.
我已经搜索了 stackoverflow 并阅读了至少十几个与我相似的帖子,但我无法弄清楚我的个人问题。
Basically, I am trying to pass the NSMutableDictionary from the modal view to the master view. Here's the code:
基本上,我试图将 NSMutableDictionary 从模态视图传递到主视图。这是代码:
QuoteMasterViewController.h:
引用MasterViewController.h:
@class QuoteModalViewController;
@interface QuoteMasterViewController : UITableViewController
@end
QuoteMasterViewController.m:
引用MasterViewController.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:
引用ModalViewController.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:
引用ModalViewController.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);
}
}
Thank you in advance for any and all help!
在此先感谢您的任何帮助!
回答by Kreiri
You didn't declare your method in header file. Add
您没有在头文件中声明您的方法。添加
-(void)addQuotationWithDictionary: (NSMutableDictionary *)myDictionary;
to QuoteMasterViewController.h file between @interface QuoteMasterViewController
and @end
.
到@interface QuoteMasterViewController
和之间的 QuoteMasterViewController.h 文件@end
。