Driving Task Crash When Adding Action Sheet or Alert

I have a driving task app and am trying to show a CPActionSheetTemplate or a CPAlertTemplate. Both of these are crashing showing:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported object <CPActionSheetTemplate: 0x6000030319e0> <identifier: C744031B-99F6-4999-AF19-6ED43140502B, userInfo: (null), tabTitle: (null), tabImage: (null), showsTabBadge: 0> passed to pushTemplate:animated:completion:. Allowed classes: {(
    CPSearchTemplate,
    CPNowPlayingTemplate,
    CPPointOfInterestTemplate,
    CPListTemplate,
    CPInformationTemplate,
    CPContactTemplate,
    CPGridTemplate,
    CPMapTemplate
)}'

This is very strange, because in the docs all app types are allowed to show ActionSheets and Alerts.

Why is this crashing?

Replies

Hi! The action sheet, alert, and voice control templates are presented modally on top of the currently-visible template; they are not pushed onto the template stack. So instead of using -[CPInterfaceController pushTemplate:animated:completion:], you should use -[CPInterfaceController presentTemplate:animated:completion:].

  • *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported object <CPActionSheetTemplate: 0x28036c750> <identifier: CFE56540-A3AE-45CB-ACDF-E05C1CA003FC, userInfo: (null), tabTitle: (null), tabImage: (null), showsTabBadge: 0> passed to presentTemplate:animated:completion:. Allowed classes: {( CPListTemplate, CPNowPlayingTemplate, CPTabBarTemplate, CPAlertTemplate, CPVoiceControlTemplate, CPGridTemplate )}'

Add a Comment