2010-07-11 63 views
0

我嘗試編程與核心數據和同步服務框架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; 
} 

必須是一個非常明顯的問題,因爲谷歌只產生一個結果,這是近5年的歷史,並沒有真正有用的。

回答

0

幾件事情要檢查:

  1. 檢查您的數據模型,並確保你沒有任何錯別字。
  2. 檢查並確保您的.syncschema的相對文件路徑正確。