2011-01-19 83 views
0

我有一個方法DoSomething()在我的AppDelegate中定義了'找不到方法'編譯器警告的方法在#define指令內

這是全面落實我的appDelegate的:

#import "SampleAppAppDelegate.h" 
#import <Foundation/Foundation.h> 

#define DoSomething()\ 
NSConnection *conn = [NSConnection connectionWithRegisteredName:@"myConnection" host:nil];\ 
NSLog(@"Compiler seems to have found the class %@", [NSConnection class]);\ 


@implementation SampleAppAppDelegate 

@synthesize window; 

#pragma mark - 
#pragma mark Application lifecycle 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 
    DoSomething(); 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

- (void)dealloc { 
    [window release]; 
    [super dealloc]; 
} 

@end 

雖然如預期的那樣實現工作正常(日誌被識別類) 編譯器顯示警告:

warning: no '+connectionWithRegisteredName:host:' method found 

任何想法如何解決這個問題? 如何修改實現以擺脫警告?

+0

該警告意味着沒有接口聲明瞭具有匹配選擇器的方法。自從您導入Foundation後,您不應該得到它。這可能是從宏調用方法引起的錯誤。 – ughoavgfhw 2011-01-19 06:21:36

+1

很難從您粘貼的代碼中分辨出來。包含您的宏定義和該宏的單個用法的小程序不會生成任何警告。嘗試提供產生上述警告的最小程序。 – 2011-01-19 06:27:21

回答

0

啊,你的目標是iOS。 NSConnection在iOS SDK的公共API中不可用。

相關問題