Bird
0
0

Why do no swipe actions appear with this code?

medium📝 Debug Q7 of 15
iOS Swift - Lists and Data Display
Why do no swipe actions appear with this code?
let shareAction = UIContextualAction(style: .normal, title: "Share") { _, _, completion in
    completion(true)
}
return UISwipeActionsConfiguration(actions: [])
AUISwipeActionsConfiguration is created with an empty actions array
BUIContextualAction style .normal is invalid
CCompletion handler is missing a print statement
DThe title parameter cannot be "Share"
Step-by-Step Solution
Solution:
  1. Step 1: Check UISwipeActionsConfiguration initialization

    Creating UISwipeActionsConfiguration with an empty actions array means no actions are available.
  2. Step 2: Understand the effect

    Returning empty actions results in no swipe actions being shown when swiping.
  3. Final Answer:

    UISwipeActionsConfiguration is created with an empty actions array -> Option A
  4. Quick Check:

    Empty actions array = no swipe actions shown [OK]
Quick Trick: Always provide at least one action in UISwipeActionsConfiguration [OK]
Common Mistakes:
  • Returning empty actions array
  • Confusing style values
  • Expecting print statements to prevent issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes