没有可见的@interface类声明选择器iPhone问题

时间:2013-11-22 23:27:31

标签: ios iphone objective-c

所以我在我的app delegate.m中有这段代码 -

#import "AppDelegate.h"
#import "SearchViewController.h"

- (NSOperationQueue *) getOperationQueue
{
    if(queue == nil){
        queue = [[NSOperationQueue alloc] init];
    }

    return queue;
}

这是我的app 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 

    }

我收到错误 - &#34; AppDelegate没有可见的@interface声明选择器&#39; getOperationQueue&#39;

不确定为什么 - 谁能告诉我?

1 个答案:

答案 0 :(得分:0)

我认为,类型转换应该有效:

  

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