类无可见@interface声明选择iPhone问题
问题描述:
所以我在我的应用程序delegate.m有这样的代码 -类无可见@interface声明选择iPhone问题
#import "AppDelegate.h"
#import "SearchViewController.h"
- (NSOperationQueue *) getOperationQueue
{
if(queue == nil){
queue = [[NSOperationQueue alloc] init];
}
return queue;
}
这是我的应用程序delegate.h-
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property NSOperationQueue *queue;
- (NSOperationQueue*) getOperationQueue;
@end
在另一个
文件我有这样的事情 -
#import "AppDelegate.h"
#import "AJAXUtils.h"
+ (void)getAsyncJsonWithUrl:(NSURL *)url callback:(void (^)(NSDictionary*))callbackFunction
{
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
@try{
[NSURLConnection sendAsynchronousRequest:urlRequest
queue:[appDelegate getOperationQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *error){
//more code
}
//more code
}
我得到一个错误 - “没有可见的@interface for AppDelegate声明选择器' getOperationQueue'
不太清楚为什么 - 有谁能告诉我?
答
我认为,类型转换应该工作:
的appDelegate =(AppDelegate中*)[[UIApplication的sharedApplication] 委托];
呵呵,奇怪的一个。你有另一个AppDelegate.h可能是#imported吗? –
请显示所有相关文件的所有#imports。 –
呃...他们在不同的文件夹中?所以我猜他们在不同的项目中,这应该不重要? – praks5432