1

I was presenting a UIActionSheet on iPad with iOS 5 with no problems. Now, with iOS 6 installed on my iPad, the app crashes when doing the same thing. I have no idea how to fix the issue since my code did not change and the stack trace is hard to understand. Did someone encounter the same issue?

Initialization code of my UIActionSheet:

UIActionSheet *menu = [[[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"ExportMethod", @"") delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") destructiveButtonTitle:nil otherButtonTitles:NSLocalizedString(@"ExportMethodMail", @""), NSLocalizedString(@"ExportMethodiTunes", @""), nil] autorelease];
self.actionSheet = menu;

To present the UIActionSheet:

[self.actionSheet showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];

I also tried other possible calls:

[self.actionSheet showInView:self.view];
[self.actionSheet showFromTabBar:self.tabBarController.tabBar];
[self.actionSheet showFromRect:self.view.bounds inView:self.view animated:YES];

But, the app is always crashing at this line with the message:

Thread 6: EXC_BAD_ACCESS (code = 1, adress = 0xcc)

If I run the app without the debugger, I have the following stack trace:

 Thread 5 Crashed:
 0   libicucore.A.dylib             0x39620570 ucol_getVersion + 0
 1   TextInput                      0x36aed21a   KB::WordTrie::dictionary_versions_ok(KB::ReadOnlyDataFile const*) const + 62
 2   TextInput                      0x36aecfa4 KB::WordTrie::load(KB::String const&) + 276
 3   TextInput                      0x36ae6490 <redacted> + 12
 4   TextInput                      0x36e50cae <redacted> + 54
 5   TextInput                      0x36e50c4c <redacted> + 40
 6   TextInput                      0x36addf68 TIInputManager::load_dictionaries(KB::String const&, KB::String const&, bool) + 20
 7   TextInput                      0x36aeefbc <redacted> + 216
 8   TextInput                      0x36aeec02 <redacted> + 498
 9   UIKit                          0x356ccf7a <redacted> + 158
 10  UIKit                          0x356cbfce <redacted> + 398
 11  UIKit                          0x356cbbe2 <redacted> + 374
 12  UIKit                          0x356ca4b4 <redacted> + 460
 13  UIKit                          0x356ca1a6 <redacted> + 146
 14  UIKit                          0x3593001c <redacted> + 264
 15  UIKit                          0x3593045c <redacted> + 568
 16  UIKit                          0x3593468c <redacted> + 564
 17  UIKit                          0x35934a94 <redacted> + 136
 18  UIKit                          0x35934e5e <redacted> + 250
 19  EasyTag                        0x0002365e -[GameDetailController exportGameAsCSV] (GameDetailController.m:598)

The exportGameAsCSV method is where the UIActionSheet is presented.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
nicolas
  • 489
  • 1
  • 3
  • 22

1 Answers1

6

Thank your for your answer. The problem is that I am not not in the UI thread. According to Apple's documentation:

Important The UIKit classes are generally not thread safe. All drawing-related operations should be performed on your application’s main thread.

The following code fixes the issue:

dispatch_async(dispatch_get_main_queue(), ^{

    [self.actionSheet showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];

 });
nicolas
  • 489
  • 1
  • 3
  • 22