Getting a SIGABRT error on a new project - xcode

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.

Related

How to properly setup widget for background update on macos?

I'm building a widget for macOS, which is target for macOS only. And, it keeps crashing after an attempt to recreate another timeline (from getTimeline function)
It throws the following error:
Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[NSConcreteFileHandle fileDescriptor]: Invalid argument'
terminating with uncaught exception of type NSException
I believe it is generated due to the lack of implementation of the method onBackgroundURLSessionEvents(matching:_:), which brought my attention to the following documentation ⬇️
From Apple doc :
When your widget extension is active like when providing a snapshot or timeline, it can initiate background network requests. The process is similar to how an app handles this type of request, which is described in Downloading Files in the Background. Instead of resuming your app, WidgetKit activates your widget’s extension directly. To handle the result of the network request, use the onBackgroundURLSessionEvents(matching:_:) modifier to your widget’s configuration, and do the following:
Store a reference to the completion parameter. You call the completion handler after processing all network events.
Use the identifier parameter to find the URLSession object you used when initiating the background request. If your widget extension was terminated, use the identifier to recreate the URLSession.
After invoking onBackgroundURLSessionEvents(), the system calls the urlSession(_:downloadTask:didFinishDownloadingTo:) method of the URLSessionDelegate you supplied to the URLSession. When all events have been delivered, the system calls the delegate’s urlSessionDidFinishEvents(forBackgroundURLSession:) method.
To refresh your widget’s timeline after the network request completes, call the WidgetCenter methods from your delegate’s implementation of urlSessionDidFinishEvents. Once you finish handling the events, call the completion handler that you previously stored in onBackgroundURLSessionEvents().
The problem is that urlSessionDidFinishEvents(forBackgroundURLSession:) is only available for:
OS 7.0+
Mac Catalyst 13.0+
tvOS 9.0+
watchOS 2.0+
It seems like there is no equivalent idea for macOS targets. So, how should we set it up?

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.

Win8 - Unhandled exception in Windows.UI.Xaml.dll

I've got some strange behavior while debugging/running my metro app.
During drag'n'drop the screen will be refreshed. I'd added some functionality to block binded properties from refreshing while drag'n'drop is in progress.
But sometimes the app crash, but in stead of throwing some exception which I can debug, all I got is an window saying to open an external just-in-time-debugger
An unhandled win32 exception occurred in SOME_APP.exe [7785].
(The external debugger does not bring more information)
And the output says:
Unhandled exception at 0x05017145 (Windows.UI.Xaml.dll) in SOME_APP.exe: 0xC0000005: Access violation reading location 0x00000088.
I'm working on a x64 device.
Has somebody ever heard of such problem?
If you're passing objects implemented INotifyPropertyChanged, inherited BindableBase or DependencyObject etc. thru NavigationParameter; and bind then in the NavigatedPage (or binded them in the navigating page) you'll most likely get this error. Don't pass any object except primitive type thru NavigationParameter when navigating.
You are getting this exception because non-existent referenced methods. For example.
You have an object named Categories which inherites BindableBase.
You binded that to Home.xaml.
Home.xaml's binding mechanism subscribed the PropertyChanged event of Categories object.
You navigated the Article.xaml passing Categories object as a the NavigationParameter.
You binded the Categories object to Article.xaml.
When a property changes in Categories object; that property will fire PropertyChanged event.
There are two subscribers to that event. Home.xaml and Article.xaml, but Home.xaml is no longer exist since you navigated away from it. But your delegate holds the address of it; so it tries to Execute; and fail with Access violation error.

MPMoviePlayerController - catching network errors when loading a movie

Is there a way of catching exceptions (particularly for network errors
/ no connection available) when using a MPMoviePlayerController?
I am particularly concerned that once an instance of the player is initialised with initWithURL: you have no way of knowing whether the movie load has failed for some reason.
I have reviewed the available documentation and realise I can get a
notification for loadState changes through
moviePlayerLoadStateChanged:(NSNotification*)notification.
Problem is the loadState constants available don't cater for error handling:
MPMovieLoadStateUnknown
MPMovieLoadStatePlayable
MPMovieLoadStatePlaythroughOK
MPMovieLoadStateStalled
(in case you are wondering, MPMovieLoadStateStalled this doesn't get called during network errors for some reason?)
There's a deprecated MPMoviePlayerContentPreloadDidFinishNotification that provides a userInfo dictionary with an "error" key but nothing for iOS 3.2 and above.
Any help would be very much appreciated.
In the end I got this sorted by subscribing to MPMoviePlayerPlaybackDidFinishNotification and watching for MPMovieFinishReasonPlaybackError.
More details here https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006953-CH3-SW17

Resources