Cocoa error 256 core data

前端 未结 5 1165
时光说笑
时光说笑 2020-12-17 23:49

I have error \"Cocoa error 256\" when I try to save data. How to fix it? And what problem?

相关标签:
5条回答
  • 2020-12-18 00:06

    I get this error on Xcode 6 (& 7) when switching a network connection while the Simulator is open. For example moving from one wireless network to another. The solution for me is to Quit Simulator and restart.

    0 讨论(0)
  • 2020-12-18 00:16

    This is what it boils down to (as Tegeril said)

    NSFileReadUnknownError Read error, reason unknown

    Available in Mac OS X v10.4 and later.

    Declared in FoundationErrors.h.

    A file can also be a resource located at a URL/URI, if the URL has unencoded characters it can cause this type of error.

    Check the path to the resource/file.

    0 讨论(0)
  • 2020-12-18 00:23

    If its a core data error there is probably an actual error object somewhere near where the error occurs. If you dump the error objects userInfo dictionary, you can usually get a lot more detail than just the error code itself.

    0 讨论(0)
  • 2020-12-18 00:23

    I ran into exactly this error when populating an SQLite database for an iOS app using a custom script (ie not using Core Data). It turns out that there is some metadata which you have to update yourself, after adding new rows. Find the row in Z_PRIMARYKEY where Z_NAME equals the name of the table you've just inserted into. Make sure that Z_MAX in this row is equal to the highest value of Z_PK in the table you've inserted the rows into. In my case, as soon as I updated Z_MAX with the correct number, the error went away.

    So, for the "ZAUTHOR" table:

    SELECT z_pk FROM ZAUTHOR ORDER BY z_pk DESC LIMIT 1; /* Returns 1234 */
    UPDATE Z_PRIMARYKEY SET z_max = 1234 WHERE z_name = 'Author';
    

    This is the article which helped me track down the error.

    0 讨论(0)
  • 2020-12-18 00:24

    According to the help reference in Xcode:

    NSFileReadUnknownError Read error, reason unknown

    Available in Mac OS X v10.4 and later.

    Declared in FoundationErrors.h.

    Sadly, that's probably not too helpful, though it is an unknown -read- error.

    0 讨论(0)
提交回复
热议问题