Sergey Zenchenko
Sergey Zenchenko

Reputation: 864

Cocoa error 256 core data

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

Upvotes: 8

Views: 16757

Answers (5)

Joel
Joel

Reputation: 16134

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.

Upvotes: 0

oalders
oalders

Reputation: 5279

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.

Upvotes: 2

Richard Stelling
Richard Stelling

Reputation: 25665

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.

Upvotes: 2

TechZen
TechZen

Reputation: 64428

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.

Upvotes: 2

Aaron
Aaron

Reputation: 4614

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.

Upvotes: 6

Related Questions