自定义 Cocoa 框架以及使用它的问题
我制作了一个自定义可可框架只是为了进行实验并找到制作框架的最佳方法,但在使用它时遇到了问题。框架项目构建和编译得很好,但是当我在 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
Method.h:
#import <Cocoa/Cocoa.h>
@interface Method : NSObject {
}
+ (void)logStart:(NSString *)test:(NSString *)test2;
@end
Method.m:
#import "Method.h"
@implementation Method
+ (void)logStart:(NSString *)test:(NSString *)test2 {
NSLog(test);
NSLog(test2);
}
@end
如果有人知道为什么我收到此错误请回复。
感谢您的帮助
I made a custom cocoa framework just to experiment and find the best way to make one but ran in to a problem using it. The framework project builds and compiles just fine, but when I use it in an xcode project I get the error, 'LogTest' undeclared
. The name of the framework is LogTest
Heres the code to my app that uses the framework:
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
Framework Code........
LogTest.h:
#import <Cocoa/Cocoa.h>
#import "Method.h"
@protocol LogTest //Not sure if this is needed I just wanted a blank header
@end
Method.h:
#import <Cocoa/Cocoa.h>
@interface Method : NSObject {
}
+ (void)logStart:(NSString *)test:(NSString *)test2;
@end
Method.m:
#import "Method.h"
@implementation Method
+ (void)logStart:(NSString *)test:(NSString *)test2 {
NSLog(test);
NSLog(test2);
}
@end
If anyone knows why I am getting this error please reply.
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从我看到的你刚刚发布的头文件来看。 LogTest 不是一个类,而是一个空协议。您应该在
Method
上调用logStart::
,而不是LogTest
IOW。将其更改为
From what I see of the header files you just posted. LogTest is not a class but an empty protocol. You should be calling
logStart::
onMethod
notLogTest
IOW. change it to