Zimm/libdisplaystack — Issue #1: deactivateTopApplicationAnimated: Crashes SpringBoard
Author: Tyr0
Created: 2012-02-25 23:08:13+00:00
State: open

Calling [[DSDisplayController sharedInstance] deactivateTopApplicationAnimated:NO] crashes SpringBoard with syslog reading:

Feb 25 15:04:26 My-Elastic-Eye SpringBoard[4194]: From app display identifier is: com.apple.mobiletimer
Feb 25 15:04:26 My-Elastic-Eye SpringBoard[4194]: -[__NSCFNumber maximumLengthOfBytesUsingEncoding:]: unrecognized selector sent to instance 0x3401b0
Feb 25 15:04:26 My-Elastic-Eye SpringBoard[4194]: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber maximumLengthOfBytesUsingEncoding:]: unrecognized selector sent to instance 0x3401b0'
*** First throw call stack:
(0x32f368bf 0x35bfe1e5 0x32f39acb 0x32f38945 0x32e93680 0x5cae7 0x4d89b 0x3e559 0x36f3681b 0x36f3bfb9 0x4830ecf 0x364f2ba7 0x34db3e8d 0x32f092dd 0x32e8c4dd 0x32e8c3a5 0x33ba4fcd 0x36f4f743 0x24a33 0x24074)
Feb 25 15:04:26 My-Elastic-Eye com.apple.SpringBoard[4194]: terminate called throwing an exception

My fix for this was to use the following instead:

SBUIController *aUIController = [objc_getClass("SBUIController") sharedInstanceIfExists];

if (aUIController) {
if ([aUIController respondsToSelector:@selector(clickedMenuButton)]) {
[aUIController clickedMenuButton];
}
}