CanDestroy tag doesn't work in 1.18

People say "can destroy" lets you break some things in adventure mode, but every time I try it, it does not work in 1.18.
Is there a way to make it work?
Here's my command:

/give @p minecraft:stick 1 0 {candestroy["iron_bar"]}

Solution 1:

Seems like you're using syntax from before 1.13, as in update 1.13 Mojang removed numeric block data values and shifted the data tag to become part of the item specification. The following should do what you want:

/give @p minecraft:stick{CanDestroy:["minecraft:iron_bar"]} 1