'NSInternalInconsistencyException', reason: is not a subclass of NSManagedObject.' - core-data

In my APP I have a really simple model with just two classes. One of those is CDAttribute.
This APP is in the store and was working. Now I tested it the fist time with xCode 6 today and put a new version of it on my iPad. Now I get this error
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '"CDAttribute" is not a subclass of NSManagedObject.'
*** First throw call stack:
(0x18342e084 0x193e800e4 0x1830f5350 0x183113f94 0x10004450c 0x100043410 0x1833d4434 0x1833137e0 0x18420b6c0 0x10003f758 0x187e3f104 0x187e432dc 0x187e47624 0x187e46b00 0x187e46a58 0x187e3a38c 0x18b605640 0x1833e6360 0x1833e5468 0x1833e3a8c 0x183311664 0x18c41f5a4 0x187c16984 0x10004d0a0 0x1944eea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
calling this fuction
CDAttribute *attr = (CDAttribute *)[NSEntityDescription insertNewObjectForEntityForName:#"CDAttribute" inManagedObjectContext:self.managedObjectContext];
Which I can't understand because I didn't touch the model nor the code.

It seems like CDAttribute is reserved in iOS8. I changed the Classname (not the table name in the model, because then I'd probably loose all my entries when I update to this version) to SIAttribute and it worked.
It was the solution, however I'd be intrested if its really reserved and where it is documented.

Related

Change project file name in Xcode 10

I am trying to change a Project name in Xcode 10 and I have tried all the suggested methods I could find;
Rename project
Rename the Scheme
Rename the folder with your assets
Rename the Build plist data
I do all the above steps and the project complies and builds with out issues.
When I load the app on a iPhone, it crashed when I select a specific screen and I get the following errors;
2019-07-29 17:56:13.315622-0400 SkeetLauncher_RevA[736:163909] Unknown class _TtC14SKEET_LAUNCHER13launchButtons in Interface Builder file.
2019-07-29 17:56:13.363768-0400 SkeetLauncher_RevA[736:163909] [Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once.
2019-07-29 17:56:13.372489-0400 SkeetLauncher_RevA[736:163909] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x101d01910> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key DELAY.'
*** First throw call stack:
(0x18f237ea0 0x18e409a40 0x18f15197c 0x18fbe320c 0x1bbce65e4 0x1bbf5fa5c 0x18f121748 0x1bbf5c6cc 0x1bbced25c 0x1bbcedc08 0x1bbceded0 0x1bbcee63c 0x1bbc46e28 0x1bbc5b8e8 0x1bbc5cdbc 0x1bbc3efac 0x1bc75aea4 0x19382ac70 0x19382fc00 0x19378e718 0x1937bd04c 0x1937bdeb4 0x18f1c77a8 0x18f1c243c 0x18f1c29dc 0x18f1c21cc 0x191439584 0x1bc2b5054 0x100c453f4 0x18ec82bb4)
libc++abi.dylib: terminating with uncaught exception of type NSException.
The project compiles and runs fine before I do the rename process.
Go into the storyboard and reenter all the view controller class names.
That didn't work but it pointed me in the right direction, Thanks
I had to change the "Module" for "Custom Class" in identity inspector. I guess the "Change Project Name" process didn't automatically do it for all the view controllers. Attached is picture for clarification.
MODULE in Identity Inspector

Do I have to use weak properties to model parent-children relationships in Core Data?

I know it seems a stupid question, but after modelling the typical master-detail or parent-children relationship in Core Data, I want to create the NSManagedObject subclasses and I realised Core Data code generator is always using strong/retain for the parent properties. Is that right? In a normal object graph that is wrong because we have a retain cycle, but not sure in the Core Data context, because I guess the code generator should generate the code properly. Thanks for suggestions.
After trying to use weak properties in my NSManagedObject subclasses, I receive:
2016-03-15 11:57:36.921 WWWWW[84639:1153803] CoreData: error: Property 'company' is marked __weak on class 'Package'. Cannot generate a setter method for it.
2016-03-15 11:57:36.921 WWWW[84639:1153803] -[Package setCompany:]: unrecognized selector sent to instance 0x7f97917068e0
2016-03-15 11:57:36.933 WWWW[84639:1153803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Package setCompany:]: unrecognized selector sent to instance 0x7f97917068e0'

unrecognised exception in windows C++ code

We have a number of sections of code in the format:
try
{
// code
}
catch(std::exception &e)
{
// log exception
}
catch(...)
{
// log unknown exception.
}
Every so often, the unknown exception code triggers, and logs an unknown exception.
I always thought that all exceptions were meant to derive from std::exception, and thus catching std::exception would catch all exceptions.
Is there some other exception that I should be catching?
If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
edit
We managed to locate the cause of the problem- despite saying that they had, the customer had not installed .NET 3.5, which our code depends on, and the system fell over when trying to use the XML parser.
Is there some other exception that I should be catching?
This depends on your code. Libraries you call can throw exceptions not derived from std::exception, examples are MFC's CException or Microsoft's _com_error. Also, an access violation might be catched by catch(...), which is the reason why I would not use catch(...) in my code - it's just to broad for me.
2.If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
You can run your code in the debugger and configure the debugger to break your program when the exception is thrown (first chance). Then you know exactly which line of code triggers the exception and should be able to see what exactly is thrown.

com.facebook.presto.server.PrestoServer Guice creation errors

I got the following error when trying to start presto server, how can I diagnose what property is malformed or something else? Thanks.
config file:
coordinator=true
datasources=jmx
http-server.http.port=8080
presto-metastore.db.type=h2
presto-metastore.db.filename=var/db/MetaStore
task.max-memory=1GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080
exception is
2013-11-11T11:11:39.582-0800 ERROR main com.facebook.presto.server.PrestoServer Guice creation errors:
1) Error: Constraint violation with property prefix '': environment is malformed (for class io.airlift.node.NodeConfig)
at io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error
com.google.inject.CreationException: Guice creation errors:
1) Error: Constraint violation with property prefix '': environment is malformed (for class io.airlift.node.NodeConfig)
at io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435) ~[guice-3.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154) ~[guice-3.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) ~[guice-3.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:95) ~[guice-3.0.jar:na]
at io.airlift.bootstrap.Bootstrap.initialize(Bootstrap.java:277) ~[bootstrap-0.84.jar:0.84]
at com.facebook.presto.server.PrestoServer.run(PrestoServer.java:137) ~[presto-server-0.52.jar:0.52]
at com.facebook.presto.server.PrestoServer.main(PrestoServer.java:50) ~[presto-server-0.52.jar:0.52]
Apologies for the very unfriendly and unhelpful error message. This is on our list of things to fix.
The error "environment is malformed" means that the node.environment property (in the node.properties file) is set but fails to match the following regular expression: [a-z0-9][_a-z0-9]*. In other words, it must be lowercase, start with an alphanumeric character, and have only alphanumeric or underscores in subsequent characters.
Try a simpler name like test or production.
Not that it's of consolation, but I am getting something similar on Centos:
1) Error: Constraint violation with property prefix '': environment
may not be null (for class io.airlift.node.NodeConfig) at
io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error com.google.inject.CreationException: Guice creation errors:

Crashing on saving a managedObjectContext, with 'NSInvalidArgumentException', but only sporadically

I keep getting crashes from a save: command on a managedObjectContext. It doesn't even fulfill the NSLog statement so I don't see the unresolved error statement, so I can't figure out what the problem might be. It doesn't happen every time, but only sporadically.
Here's the code (which basically wants to increment a counter):
if ([[managedObject valueForKey:#"canSee"]boolValue]){
int read = [[managedObject valueForKey:#"timesRead"] intValue] +1;
[managedObject setValue:[NSNumber numberWithInt:read] forKey:#"timesRead"];
NSError *error;
if (![resultsController.managedObjectContext save:&error]) { //<-- crashes on this line!
NSLog(#"Unresolved Core Data Save error %#, %#", error, [error userInfo]);
exit(-1);
}
In the console window I get messages like this:
2010-08-20 08:12:20.594 AppName[23501:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet controllerWillChangeContent:]: unrecognized selector sent to instance 0xe54f560'
or this:
2010-08-20 08:12:20.594 AppName[23501:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet controllerWillChangeContent:]: unrecognized selector sent to instance 0xe54f560'
or even this:
2010-08-19 23:09:59.337 AppName[761:307] Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. -[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860 with userInfo (null)
2010-08-19 23:09:59.356 AppName[761:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860'
Then it shows the call stack at first throw, followed by a notice (terminate called after throwing an instance of 'NSException', '[Switching to process 23501]' and 'Program received signal: “SIGABRT”.'
I think the problem has something to do with CoreData but I'm not sure. I've cleaned my build and targets and it doesn't seem to help. I've tried locking/unlocking the ManagedObjectContext and it doesn't help.
Any ideas here on where to start to look for a resolution would be greatly appreciated!
Looks like you are releasing a UIViewController and not releasing its associated NSFetchedResultsController. The NSFetchedResultsController is trying to notify its delegate (most likely your UIViewController) of the save on exit.
To elaborate on Marcus' answer, you need to make sure you nil out the delegate for your NSFetchedResultsController when your view disappears:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.fetchedResultsController.delegate = nil;
}

Resources