Crash Reporter

Please share your functions/code-snips

Crash Reporter

Postby udo.killermann » Sat May 19, 2012 4:48 pm

Board,

sometimes it can get really annoying that the Crash Reporter (see below) shows up after your application just failed you and exit with an exception. The Crash Reporter looks like this:
reporterInAction.jpg
reporterInAction.jpg (20.38 KiB) Viewed 1050 times


I just press [ignore] every time, but I don't want to be alerted in the first place.

Here is a class (UKCrashReporter.NSObject) I constructed as a helper to disable Crash Reporter in some situations:
Code: Select all
Dim bCrashReporter As Boolean

Function crashReporter() As Boolean
  Return bCrashReporter 
End Function

Sub setCrashReporter(state As Boolean)
  bCrashReporter = state
 
  If (bCrashReporter) Then
    Log(Bash("/usr/bin/defaults write com.apple.CrashReporter DialogType developer"))
Else
    Log(Bash("/usr/bin/defaults write com.apple.CrashReporter DialogType server"))
  End If
End Sub

Crash Reporter is controlled via user defaults and I could have used NSUserDefaults but the command line just comes in handy.

The methods are thought to work at the class level and should be used this way:
Code: Select all
' Global Object:
' this method isn't there at all - just demo
Declare Function "NSString" + (void)helloWorld

Dim myArrRead As Array
Dim myArrWrite As Array

Event AwakeFromNib()
  Dim myReporter As UKCrashReporter
 
  myReporter.setCrashReporter(No)
 
  ' do something wrong
  NSString.helloWorld()
 
End Event


Give it a try and comment back to me.

Regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Return to Code examples

Who is online

Users browsing this forum: No registered users and 0 guests

cron