草庐IT

iphone - 无法保存到数据存储 : The operation couldn’t be completed.(Cocoa 错误 133020。)

coder 2023-09-23 原文

我正在开发相当复杂的应用程序,它在 iphone 和网络服务器之间具有巨大的同步过程。我在添加记录方面没有任何问题,直到我在单独的线程中运行同步程序,它会更新服务器上的数据,并将它们发送回 iphone。但是在此过程之后,插入新数据会导致错误,例如:

2011-01-07 12:49:10.722 App[1987:207] Failed to save to data store: The operation couldn’t be completed. (Cocoa error 133020.)
2011-01-07 12:49:10.724 App[1987:207]   {
    conflictList =     (
        "NSMergeConflict (0x5ac1ea0) for NSManagedObject (0x5a2d710) with objectID '0x5a27080 <x-coredata://E82E75ED-96DB-4CBF-9D15-9CC106AC0052/uzytkownicy/p10>' with oldVersion = 9 and newVersion = 21 and old object snapshot = {\n    adres = \"<null>\";\n    haslo = xxxxxxxxxxxxxxxxxxxxxx;\n    \"id_uzytkownika\" = 3;\n    imie = Jan;\n    \"kod_jednorazowy\" = 0;\n    komorka = \"<null>\";\n    login = nowakjan;\n    nazwisko = Nowak;\n    pesel = 0;\n    rodzaj = 2;\n    \"stan_konta\" = 0;\n    telefon = \"<null>\";\n    \"uzytkownicy_uczniowie\" = \"<null>\";\n    \"zmienna_losowa\" = 8G9e1;\n} and new cached row = {\n    adres = \"<null>\";\n    haslo = xxxxxxxxxxxxxxxxxxxxxx;\n    \"id_uzytkownika\" = 3;\n    imie = Jan;\n    \"kod_jednorazowy\" = 0;\n    komorka = \"<null>\";\n    login = nowakjan;\n    nazwisko = Nowak;\n    pesel = 0;\n    rodzaj = 2;\n    \"stan_konta\" = 0;\n    telefon = \"<null>\";\n    \"uzytkownicy_uczniowie\" = \"<null>\";\n    \"zmienna_losowa\" = 8G9e1;\n}",
        "NSMergeConflict (0xd266990) for NSManagedObject (0xcd05950) with objectID '0x5a453b0 <x-coredata://E82E75ED-96DB-4CBF-9D15-9CC106AC0052/uczniowie/p125>' with oldVersion = 5 and newVersion = 10 and old object snapshot = {\n    adres = \"Warszawa; ul. Lwowska 32\";\n    \"data_urodzenia\" = \"1997-02-01 23:00:00 +0000\";\n    dysfunkcje = \"\";\n    email = \"<null>\";\n    frekwencja = 0;\n    \"id_ucznia\" = 86;\n    imie2 = Marian;\n    \"imie_ucznia\" = \"S\\U0142awomir\";\n    klasa = \"0x5a47820 <x-coredata://E82E75ED-96DB-4CBF-9D15-9CC106AC0052/zespoly/p9>\";\n    komorka = \"<null>\";\n    \"miejsce_urodzenia\" = Warszawa;\n    \"nazwisko_ucznia\" = \"S\\U0142awek\";\n    \"numer_ewidencyjny\" = 20;\n    opiekun1 = \"Mariusz S\\U0142awek\";\n    opiekun2 = \" \";\n    pesel = 97020298919;\n    plec = 1;\n    telefon = 890000002;\n    \"uzytkownicy_uczniowie\" = \"<null>\";\n    \"web_klasa\" = 50;\n} and new cached row = {\n    adres = \"Warszawa; ul. Lwowska 32\";\n    \"data_urodzenia\" = \"1997-02-01 23:00:00 +0000\";\n    dysfunkcje = \"\";\n    email = \"<null>\";\n    frekwencja = 0;\n    \"id_ucznia\" = 86;\n    imie2 = Marian;\n    \"imie_ucznia\" = \"S\\U0142awomir\";\n    klasa = \"0x5a8e7c0 <x-coredata://E82E75ED-96DB-4CBF-9D15-9CC106AC0052/zespoly/p9>\";\n    komorka = \"<null>\";\n    \"miejsce_urodzenia\" = Warszawa;\n    \"nazwisko_ucznia\" = \"S\\U0142awek\";\n    \"numer_ewidencyjny\" = 20;\n    opiekun1 = \"Mariusz S\\U0142awek\";\n    opiekun2 = \" \";\n    pesel = 97020298919;\n    plec = 1;\n    telefon = 890000002;\n    \"uzytkownicy_uczniowie\" = \"<null>\";\n    \"web_klasa\" = 50;\n}",
        "NSMergeConflict (0xd2669b0) for NSManagedObject (0x5a44480) with objectID '0x5a47830 <x-coredata://E82E75ED-96DB-4CBF-9D15-9CC106AC0052/przedmioty/p12>' with oldVersion = 7 and newVersion = 15 and old object snapshot = {\n    \"id_przedmiotu\" = 1;\n    \"nazwa_przedmiotu\" = Historia;\n    \"skrot_nazwy\" = Hist;\n} and new cached row = {\n    \"id_przedmiotu\" = 1;\n    \"nazwa_przedmiotu\" = Historia;\n    \"skrot_nazwy\" = Hist;\n}"
    );
}

我一直在寻找任何解决方案,但没有运气。

提前感谢您提供的任何有用帮助。


    oceny_ucznia *nowaOcenka = (oceny_ucznia *)[NSEntityDescription insertNewObjectForEntityForName:@"oceny_ucznia" inManagedObjectContext:[Factory getVar:@"context"]];

    nowaOcenka.przedmiot                = (przedmioty *) [Factory getVar:@"cPrzedmiot"];
    nowaOcenka.web_przedmiot            = [NSNumber numberWithInt:[((przedmioty *)[Factory getVar:@"cPrzedmiot"]).id_przedmiotu intValue]];
    nowaOcenka.nauczyciel               = (uzytkownicy *)[Factory getVar:@"cNauczyciel"];
    nowaOcenka.web_nauczyciel           = [NSNumber numberWithInt:[((uzytkownicy *)[Factory getVar:@"cNauczyciel"]).id_uzytkownika intValue]];
    nowaOcenka.lekcja                   = (lekcje *)[Factory getVar:@"cLekcja"];
    nowaOcenka.uczen                    = uczeniek;
    nowaOcenka.web_uczen                = [NSNumber numberWithInt:[uczeniek.id_ucznia intValue]];
    nowaOcenka.czas_wpisania            = [NSDate date];

    if ( grupka != nil ) {
        nowaOcenka.grupa                = grupka;
        nowaOcenka.web_grupa            = [NSNumber numberWithInt:[grupka.id_grupy_ocen intValue]];
        nowaOcenka.kolumna              = [NSNumber numberWithInt:([kolumienka intValue]+1)];
        nowaOcenka.grupa.czas_wpisania  = [NSDate date];
    } else {
        int wartoscOceny                = [[Factory getVar:@"cSemestr"] intValue];
        wartoscOceny                   += ( [kolumienka intValue]==0 ) ? 2 : 0;
        nowaOcenka.koncowa              = [NSNumber numberWithInt:wartoscOceny];
    }

    nowaOcenka.wartosc                  = [NSNumber numberWithFloat:[[((slownik_ocen *)[self.slownikOcen objectAtIndex:[ocena selectedRowInComponent:0]]) wartosc_liczbowa] floatValue]];
    nowaOcenka.ocena                    = [NSString stringWithFormat:@"%@",[((slownik_ocen *)[self.slownikOcen objectAtIndex:[ocena selectedRowInComponent:0]]) ocena_opis]];
    nowaOcenka.semestr                  = [NSNumber numberWithInt:[[Factory getVar:@"cSemestr"] intValue]];

    ((lekcje *)[Factory getVar:@"cLekcja"]).czas_wpisania = [NSDate date];

    NSError* error;
if(![[Factory getVar:@"context"] save:&error]) {
        NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
        NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
        if(detailedErrors != nil && [detailedErrors count] > 0) {
            for(NSError* detailedError in detailedErrors) {
                NSLog(@"  DetailedError: %@", [detailedError userInfo]);
            }
        }
        else {
            NSLog(@"  %@", [error userInfo]);
        }
}

工厂类描述here ,但可能存在上下文问题,在同步过程后未准确刷新。

最佳答案

根据:

http://developer.apple.com/library/ios/#documentation/cocoa/Reference/CoreDataFramework/Miscellaneous/CoreData_Constants/Reference/reference.html

那个错误是NSManagedObjectMergeError:

Error code to denote that a merge policy failed—Core Data is unable to complete merging.

NSError 对象可以帮助解码这个错误。您可以发布用于插入新数据的代码吗?

关于iphone - 无法保存到数据存储 : The operation couldn’t be completed.(Cocoa 错误 133020。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4625232/

有关iphone - 无法保存到数据存储 : The operation couldn’t be completed.(Cocoa 错误 133020。)的更多相关文章

  1. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  2. ruby-on-rails - Rails 常用字符串(用于通知和错误信息等) - 2

    大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje

  3. ruby - 解析 RDFa、微数据等的最佳方式是什么,使用统一的模式/词汇(例如 schema.org)存储和显示信息 - 2

    我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i

  4. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  5. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  6. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  7. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  8. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  9. ruby - 无法覆盖 irb 中的 to_s - 2

    我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)

  10. ruby - 无法在 60 秒内获得稳定的 Firefox 连接 (127.0.0.1 :7055) - 2

    我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类

随机推荐