Cocoa CoreData and non-Document-Based Application - cocoa

i have a Problem wich drives me crazy...
I want to "write" a Cocoa CoreData Application, write is not the exact term, because the Application should be created with Bindings.
It was no Problem to create a Document-Based Application, it works fine.
But i want a Non-Document-Based Application, so I thought "Do the same like at the Document-Based App", but if I do so the Application do not start. XCodes' GDB says:
2010-07-14 11:02:39.894 nonDocBased[1242:a0f] An uncaught exception was raised
2010-07-14 11:02:39.899 nonDocBased[1242:a0f] [<NSApplication 0x100408e90> valueForUndefinedKey:]: this class is not key value coding-compliant for the key managedObjectContext.
2010-07-14 11:02:39.902 nonDocBased[1242:a0f] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSApplication 0x100408e90> valueForUndefinedKey:]: this class is not key value coding-compliant for the key managedObjectContext.'
So I googled on this, but found nothing helpful (or probably I was just too unexperienced... ).
But I found a Tutorial (http://www.raywenderlich.com/934/core-data-tutorial-getting-started) and tried it without Bindings but this neither works.
So my Question is how do I create a Non-Document-Based Application using Core Data?
Here's my Code, the Password is stackoverflow.
Thanks for any Ideas...
Dennis

Bind the NSArrayController managedObjectContext to your AppDelegate not to Files's owner.

Related

Swift 4 NSUnknownKeyException Error

After yesterdays update I got a pretty strange error when trying to run my app.
2018-06-14 10:38:25.882062+0200 Sorglos Lagerbestand[377:21124] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Sorglos_Lagerbestand.genexis 0x1017d05d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lbl_titanium.'
I got three ViewControllers which got all the same function. 2 are working just fine without any problem but the third one is not working at all. Everytime I'm trying to get into that buggy viewcontroller the app freezes.
You guys got any solution for that?
Whole code: https://hastebin.com/vegoboxipo.swift

Changing the name of an IBACTION now gives an uncaught exception error

OK this one is hopefully really simple
I thought I had it figured out once but can't remember what I did
In any app I go in and create a connection to a button or whatever and I give it a name like "PressThisButtonWhenDone"
this is all good and it works fine
BUT
I then want to change the name to "PressThisButtonWhenFinished"
so I delete the old action and create the new one with this name and I go into the .m file to remove the old action Xcode put in place automatically for me and place any code I had in the old method in the new properly named one.
I then build the project and it goes just fine the app comes up and I use all the other functions just fine and then I hit the Button associated with "PressThisButtonWhenFinished"
and I get something along these lines...
2014-06-03 12:30:18.148 appname[5602:60b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ViewController 0x12ed27d10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key PressThisButtonWhenDone.'
*** First throw call stack:
(0x18cb66f50 0x1990701fc 0x18cb66bd4 0x18d624720 0x18cab25ec 0x18feeadd0 0x18fe2f878 0x18fb30488 0x18fb303f4 0x18fcdd868 0x18fbe7f54 0x18fbe7d24 0x18fbe7ca4 0x10241299c 0x18fb2aff8 0x18f71c258 0x18f716e20 0x18f716cd8 0x18f716560 0x18f716304 0x18fb2f16c 0x18cb27644 0x18cb269a0 0x18cb24c38 0x18ca65c20 0x19274dc0c 0x18fb96fdc 0x10009d6fc 0x199663aa0)
libc++abi.dylib: terminating with uncaught exception of type NSException
This is the old button name and I cannot locate it anywhere to remove it
I tried doing a clean not sure if that would do anything and it did nothing How do I eliminate this error
As it turns out there was still a connection to the old name and that was the reason for the error.By going to the connections manager I found the new connection was there and so was the old one. I deleted the old one and it works fine now. I knew it would be a simple fix.

THREAD 1 SIGABRT error

I just started with Xcode programming and I encountered my first problem when I run my app without any extra codes, methods, properties or classes. I started with the template SINGLE VIEW and I changed the .xib to MainWindow and added an object called basically App Delegate. I removed the single view object from the MainWindow.xib and replaced it with a UIWindow.
I receive the following classic THREAD 1 SIGABRT error:
App[4178:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ViewController" nib but the view outlet was not set.'
*** First throw call stack:
(0x14f8022 0xef8cd6 0x14a0a48 0x14a09b9 0x1222dd 0x122779 0x12299b 0x81401 0x81670 0x81836 0x8872a 0x1ff5 0x59386 0x5a274 0x69183 0x69c38 0x5d634 0x13e2ef5 0x14cc195 0x1430ff2 0x142f8da 0x142ed84 0x142ec9b 0x59c65 0x5b626 0x1d2d 0x1c95 0x1)
terminate called throwing an exception(lldb)
I already reviewed existing postings, but I could not get wiser on it.
It seems very confusing, but is actually very simple. The Thread1: SIGABRT glitch means that something is interrupting your connections.
This may be caused by declaring your connection as weak, and declaring it as strong in your code. In order to tell what you declared your connection by clicking on the object that is having the problem, and then going to the connections inspector (the symbol with a circled arrow). This will let you see the connection.
Now try changing your code declaration from strong to weak (or the other way around), then running your program. If this does not work try deleting the code of the entity, and deleting the connection by hovering over it in the connections inspector and clicking the "X" that shows up.
After deleting the connection, and code try reconnecting the entity and the code should reinstall by itself.

Getting a SIGABRT error on a new project

I started getting a weird error in my project, so I created a whole new document-based project just to test (in Xcode 4). I added a 'Text View' to the Document.xib, and ran the program. I manage to open a few new documents, type some stuff in the text view, then I pause, and then the program terminates. It gives me: "Program received signal "SIGABRT".
The error is in the default document.m file, in method:
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
on line:
#throw exception
What's going on?
PS. I looked at the Activity Monitor, and all the loads: System Load, User Load, go way up all at once before it quits.
From the docs:
The default implementation of this method throws an exception because
at least one of the writing methods (this method,
writeToURL:ofType:error:, fileWrapperOfType:error:, or
writeToURL:ofType:forSaveOperation:originalContentsURL:error:) must be
overridden.
My guess is that you didn't implement these method(s). I also bet you're on Lion and have autosaving enabled (see +autosavesInPlace), and that the exception is thrown when the app tries to autosave after an internal timer / change watcher is triggered.

XCode 4.2 Implement Core Data to my existing project is not working

I have a project and I want to add the Core Data handling. I have read a lot of documents and questions on the internet and on this site, but I have an error and I can't fix it.
Basically, I use for the implementation this site:
http://www.theappcodeblog.com/2011/08/08/add-core-data-to-an-existing-project-in-xcode-4/
and I created a new project with core data supporting in xcode for helping me in my project. But I cant copy my project code to the core data supported xcode project.
So I have the coredata framework included, and imported in the pch file. AppDelegate.m and .h files are has the core data functions and properties.
I created a xcdatamodeld with name "User.xcdatamodeld" and with the class file which name User.h and User.m
When I try to start my application I got this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
The error come from the managedObjectModel getter method line, where the managedObjectModel is null.
I have tried to some another thing, for example, replace the line:
managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
to:
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
but with this line I got this error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
With the first line, I debugged the modelURL and the debug line ends is: /diary.app/User.momd/
The User.momd dir is exist and has a User.mom file.
My question is same like that: Cannot create an NSPersistentStoreCoordinator with a nil model
But the momd to mom replacing not works for me.
So what I doing wrong?
Many thanks!
EDIT
I found the solution (my weekend day was gone...):
start a new project with core data, and full copy the appdelegate functions and properties. Only this works for me!

Resources