2013-11-22 32 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] 委託];

相關問題