2013-11-22 31 views
-2

所以我在我的应用程序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'

不太清楚为什么 - 有谁能告诉我?

+1

呵呵,奇怪的一个。你有另一个AppDelegate.h可能是#imported吗? –

+0

请显示所有相关文件的所有#imports。 –

+0

呃...他们在不同的文件夹中?所以我猜他们在不同的项目中,这应该不重要? – praks5432

回答

0

我认为,类型转换应该工作:

的appDelegate =(AppDelegate中*)[[UIApplication的sharedApplication] 委托];

相关问题