【发布时间】:2011-05-22 16:01:14
【问题描述】:
我制作了一个定制的可可框架,只是为了试验并找到制作它的最佳方法,但在使用它时遇到了问题。框架项目的构建和编译都很好,但是当我在 xcode 项目中使用它时,我得到了错误,'LogTest' undeclared。框架名称是LogTest
这是我使用该框架的应用程序的代码:
TestAppDelegate.h:
#import <Cocoa/Cocoa.h>
#import <LogTest/LogTest.h>
@interface TestAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
}
@property (assign) IBOutlet NSWindow *window;
@end
TestAppDelegate.m:
#import "TestAppDelegate.h"
@implementation TestAppDelegate
@synthesize window;
- (void)awakeFromNib {
[LogTest logStart:@"testing 123":@"testing 1234"]; //This is the line where the error occurs
}
@end
框架代码.......
LogTest.h:
#import <Cocoa/Cocoa.h>
#import "Method.h"
@protocol LogTest //Not sure if this is needed I just wanted a blank header
@end
方法.h:
#import <Cocoa/Cocoa.h>
@interface Method : NSObject {
}
+ (void)logStart:(NSString *)test:(NSString *)test2;
@end
方法.m:
#import "Method.h"
@implementation Method
+ (void)logStart:(NSString *)test:(NSString *)test2 {
NSLog(test);
NSLog(test2);
}
@end
如果有人知道我为什么会收到此错误,请回复。
感谢您的帮助
【问题讨论】:
-
能把Logtest.h的内容包含进去吗?
-
是您帖子中说 AppDelegate.h 和 AppDelegate.m 的错别字吗?头文件命名为 TestAppDelegate.h 对吧?
-
是的,感谢您注意到我会修复它们。
-
happyCoding25:你不需要那个协议。具有仅在同一框架中导入其他标头的主标头的框架没有任何问题。 (不过,我确实质疑将您的课程命名为“方法”。)
-
“方法”这个名字只是为了测试。
标签: cocoa frameworks import void