似乎几乎是this question的副本,但那里的答案尚未解决问题。
第一
extern PlanningDocumentService *folderService;
第一
#import first.h
- (void)serviceDefinition
{
PlanningDocumentService *folderService = [_myDocumentViews objectAtIndex:[_gridView indexOfSelectedItem]];
detail.service = folderService;
}
秒
#import first.h
秒
#import second.h
+(NSArray*)getDocumentData
{
NSString *passedCaption = folderService.caption;
}
给出错误:
Undefined symbols for architecture i386:
"_folderService", referenced from:
+[GenericService getDocumentData] in GenericService.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
除了上面的文件外,我没有声明或定义
folderService
。任何想法都欢迎。
最佳答案
您需要定义folderService
以具有全局范围:
first.m:
#import "first.h"
PlanningDocumentService *folderService = nil;
- (void)serviceDefinition
{
folderService = [_myDocumentViews objectAtIndex:[_gridView indexOfSelectedItem]];
detail.service = folderService;
}