Cocoa 同步服务异常
我尝试使用 Core Data 和 Sync Services 框架编写 Cocoa 应用程序,
它工作得很好,但是一旦我尝试启动同步,我就会得到以下异常:
>[NOTE: this exception originated in the server.]
can't register schema at /Users/sdk/Documents/Knoma/build/Release/Knoma.app/Contents/Resources/KnomaSchema.syncschema: it contains references to the following undefined objects:
(
"<ISDDataClass 0x10056e1d0 [com.knoma]>{ bundleRef=<ISDFileReference 0x10051fb80 [A3F1469E-68CE-417D-AFEB-F277E0FCF6CC-46008-0000F268982A8435]]>{ path=\"/Users/sdk/Documents/Knoma/build/Release/Knoma.app/Contents/Resources/KnomaSchema.syncschema\"; mtime=2010-07-11 20:23:25 +0200; bundleId=\"(null)\"; bundleRelativePath=\"(null)\"; windowsBinRelativePath=\"(null)\"} uiHelperClassName=\"(null)\" imagePath=\"(null)\" category=\"(null)\"}"
)
我的模式的属性列表如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ManagedObjectModels</key>
<array>
<string>../../../Knoma_DataModel.mom</string>
</array>
<key>DataClasses</key>
<array>
<dict>
<key>ImagePath</key>
<string>SyncDataClass.tiff</string>
<key>Name</key>
<string>com.mycompany.knoma</string>
</dict>
</array>
<key>Name</key>
<string>com.mycompany.knoma</string>
</dict>
</plist>
负责启动的代码同步的内容如下:
- (IBAction)startSync:(id)sender {
ISyncClient * client = [self syncClient];
[[[self managedObjectContext]persistentStoreCoordinator]syncWithClient:client
inBackground:YES
handler:self
error:nil];
}
- (ISyncClient *)syncClient
{
NSString *clientIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *reason = @"Unknown Error";
ISyncClient *client;
@try {
client = [[ISyncManager sharedManager] clientWithIdentifier:clientIdentifier];
if (client == nil) {
if (![[ISyncManager sharedManager] registerSchemaWithBundlePath:[[NSBundle mainBundle]pathForResource:@"KnomaSchema" ofType:@"syncschema"]]) {
reason = @"Can't register sync schema";
} else {
client = [[ISyncManager sharedManager] registerClientWithIdentifier:clientIdentifier descriptionFilePath:[[NSBundle mainBundle] pathForResource:@"ClientDescription" ofType:@"plist"]];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeApplication];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeDevice];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeServer];
}
}
}
@catch (id exception) {
client = nil;
reason = [exception reason];
}
if (client == nil) {
NSRunAlertPanel(@"You can't sync.", [NSString stringWithFormat:@"Registration Failed: %@", reason], @"OK", nil, nil);
}
return client;
}
必须是一个非常明显的问题,因为谷歌只产生一个结果,该结果已经有五年了,而且没有真正的帮助。
I try to program a Cocoa application with Core Data and the Sync Services framework,
it works quite well, but once I try to start the sync, i get the following exception:
>[NOTE: this exception originated in the server.]
can't register schema at /Users/sdk/Documents/Knoma/build/Release/Knoma.app/Contents/Resources/KnomaSchema.syncschema: it contains references to the following undefined objects:
(
"<ISDDataClass 0x10056e1d0 [com.knoma]>{ bundleRef=<ISDFileReference 0x10051fb80 [A3F1469E-68CE-417D-AFEB-F277E0FCF6CC-46008-0000F268982A8435]]>{ path=\"/Users/sdk/Documents/Knoma/build/Release/Knoma.app/Contents/Resources/KnomaSchema.syncschema\"; mtime=2010-07-11 20:23:25 +0200; bundleId=\"(null)\"; bundleRelativePath=\"(null)\"; windowsBinRelativePath=\"(null)\"} uiHelperClassName=\"(null)\" imagePath=\"(null)\" category=\"(null)\"}"
)
My schema's property list looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ManagedObjectModels</key>
<array>
<string>../../../Knoma_DataModel.mom</string>
</array>
<key>DataClasses</key>
<array>
<dict>
<key>ImagePath</key>
<string>SyncDataClass.tiff</string>
<key>Name</key>
<string>com.mycompany.knoma</string>
</dict>
</array>
<key>Name</key>
<string>com.mycompany.knoma</string>
</dict>
</plist>
The code responsible for the start of the sync is the following:
- (IBAction)startSync:(id)sender {
ISyncClient * client = [self syncClient];
[[[self managedObjectContext]persistentStoreCoordinator]syncWithClient:client
inBackground:YES
handler:self
error:nil];
}
- (ISyncClient *)syncClient
{
NSString *clientIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *reason = @"Unknown Error";
ISyncClient *client;
@try {
client = [[ISyncManager sharedManager] clientWithIdentifier:clientIdentifier];
if (client == nil) {
if (![[ISyncManager sharedManager] registerSchemaWithBundlePath:[[NSBundle mainBundle]pathForResource:@"KnomaSchema" ofType:@"syncschema"]]) {
reason = @"Can't register sync schema";
} else {
client = [[ISyncManager sharedManager] registerClientWithIdentifier:clientIdentifier descriptionFilePath:[[NSBundle mainBundle] pathForResource:@"ClientDescription" ofType:@"plist"]];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeApplication];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeDevice];
[client setShouldSynchronize:YES withClientsOfType:ISyncClientTypeServer];
}
}
}
@catch (id exception) {
client = nil;
reason = [exception reason];
}
if (client == nil) {
NSRunAlertPanel(@"You can't sync.", [NSString stringWithFormat:@"Registration Failed: %@", reason], @"OK", nil, nil);
}
return client;
}
Has to be a quite obvious problem, as google only produces one result, which is almost five years old and not really helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几件事需要检查:
.syncschema
的相对文件路径正确。A couple of things to check:
.syncschema
has its relative file path correct.