KISS 🇺🇦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

CoreData: "incomprehensible archive" while fetching data

| comments

Automated testing (unit/integration/functional testing) is a really great way to verify your app works as expected. Also, having confidence that your refactoring won’t break anything is totally cool too. I’ve been doing some tests with CoreData entities and stumbled on a weird exception when simply fetching them.

Sample code:

1
2
3
4
5
6
NSFetchRequest *request = [NSFetchRequest new];
request.entity = entity;
request.fetchLimit = 0;
NSError *error = nil;
XCTAssertNotNil([moc executeFetchRequest:request error:&error],
                @"Failed to fetch entities: %@", error);

Here’s the exception I got in the test:

1
2
3
4
5
AwesomeProject/AwesomeProjectTests/EntityTests.m:42:
error: -[EntityTests testEntityObjectsShouldBeFetched] :
(([moc executeFetchRequest:request error:&error]) != nil) failed:
throwing "*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x5b, 0x63, 0x6f, 0x6f, 0x6c, 0x5d, 0x20, 0x21)" -
Failed to fetch entities: (null)

No error, just exception.

I couldn’t find an answer on the internets. After a while I setup a breakpoint on All Exceptions: Debug / Breakpoints / Create Exception Breakpoint. Seeing -[_NSKeyedUnarchiveFromDataTransformer transformedValue:] in the stack trace hinted me that one of the entities has a Transformable attribute with a certain class that wasn’t included in the test target. Adding it fixed the problem. Or better yet, create a mock class that simply returns the input value to minimize the application logic in the tests.

Comments