2013-12-10 81 views
0

我已经宣布在Xcode中一个不变的文件中,我已宣布Xcode的精细代码显示错误

#define MyAppDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate]) 

,然后使用MyAppDelegate每当需要。 现在我在这里得到错误,MyAppDelegate没有声明,但是当我运行这个应用程序。它运行良好,也显示我的错误。

#import "SearchResultViewController.h" 
#import "UIImageView+AFNetworking.h" 
#import "SearchResultCell.h" 

@interface SearchResultViewController() 

@end 

@implementation SearchResultViewController 
@synthesize tempArray; 
- (id)initWithStyle:(UITableViewStyle)style { 
self = [super initWithStyle:style]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad { 
[super viewDidLoad]; 
UIBarButtonItem *btnHelp = [[UIBarButtonItem alloc] initWithTitle:@"Help" style:UIBarButtonItemStylePlain target:self action:@selector(btnHelpAction:)]; 
self.navigationItem.rightBarButtonItem=btnHelp; 
self.title = @"Search Result"; 
tempArray=[[NSMutableArray alloc]init]; 
tempArray=[MyAppDelegate.searchResultArray mutableCopy]; // showing me error 
;// 

}

+0

好了,你在哪里导入'AppDelegate'其中宏指至? – nielsbot

+0

即时我的Constant.h文件....但它工作正常,我添加了一个功能,我的文件,然后突然我越来越这个错误...但如果我运行这个错误,它工作正常 – vivek

+0

你在哪里导入'Constant.h'?我没有看到它在这个列表中。 – nielsbot

回答

0

您需要导入头文件。

#import "AppDelegate.h" 
0

只需创建它像

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate]; 
tempArray=[appDelegate.searchResultArray mutableCopy]; 

不要一个实例变量忘记导入YourAppDelegate.h

#import "YourAppDelegate.h"