2012-10-29 104 views
3

我有什麼似乎是一個相當普遍的問題,但我無法弄清楚我的代碼具體有什麼問題。xcode錯誤:masterViewController沒有可見的@interface聲明選擇器

我已經淘到了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); 
    } 
} 

非常感謝您的幫助!

回答

7

你沒有在頭文件中聲明你的方法。添加

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

到QuoteMasterViewController.h文件@interface QuoteMasterViewController@end之間。

+2

非常感謝你,這正是我所需要的。男人,我喜歡這個社區。 –

相關問題