“没有找到方法”编译器警告#define指令中的方法

时间:2011-01-19 05:38:25

标签: objective-c warnings c-preprocessor

我的AppDelegate中有一个方法DoSomething()定义

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

我有什么想法可以解决这个问题? 如何修改实现以消除警告?

1 个答案:

答案 0 :(得分:0)

啊,你的目标是iOS。 iOS SDK的公共API中不提供NSConnection