Cocoa 同步服务异常

发布于 2024-09-09 04:11:34 字数 3148 浏览 1 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿透光 2024-09-16 04:11:34

有几件事需要检查:

  1. 检查您的数据模型并确保没有任何拼写错误。
  2. 检查并确保您的 .syncschema 的相对文件路径正确。

A couple of things to check:

  1. Check your data model and make sure you don't have any typos.
  2. Check and make sure your .syncschema has its relative file path correct.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文