我已經創建的C函數:調用C函數(接頭誤差)
頭
//FileSystem.h file
#import <Foundation/Foundation.h>
BOOL AddSkipBackupAttributeToItemAtURL(NSURL *url);
實施
//FileSystem.mm
#import "FileSystem.h"
#import <sys/xattr.h>
#import <Support/Support.h>
static const char* attrName = "com.apple.MobileBackup";
BOOL AddSkipBackupAttributeToItemAtURL(NSURL *url) {
BOOL operationResult = NO;
// some implementation
return operationResult;
}
當我打電話從另一個部件AddSkipBackupAttributeToItemAtURL
應用程序的一切都好,除了一個地方,我從塊調用功能。
__block UpdateFileAsyncOperation* selfOperation = self;
_contentDownloader.completionBlock = ^(NSData* data) {
[data saveForcedToPath:selfOperation.filePath];
NSURL* fileUrlWithScheme = [NSURL fileURLWithPath:selfOperation.filePath];
AddSkipBackupAttributeToItemAtURL(fileUrlWithScheme);
[runLoop removePort:port forMode:NSDefaultRunLoopMode];
[selfOperation completeOperation];
};
在那個地方,而在進步聯繫起來,有錯誤:
Undefined symbols for architecture i386:
"AddSkipBackupAttributeToItemAtURL", referenced from: __36-[UpdateFileAsyncOperation start]_block_invoke in UpdateFileAsyncOperation.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
我不明白爲什麼會發生,如何這取決於塊?我該如何解決這個問題? 謝謝!
更新:它不依賴於塊,我已經將函數的調用移動到另一個類的地方:錯誤仍然存在。我試圖找到爲什麼
可能重複[什麼名字改編,以及它是如何工作的?](http://stackoverflow.com/questions/1314743/什麼,是名-壓延和知識,確實,它工作) – 2013-08-24 13:06:37