A highly anticorrosion and self-cleaning superhydrophobic surface with hierarchical flowerlike structures fabricated on AZ91D magnesium alloy is reported in this work. The hierarchical micro/nanostructures were created through electrodeposition of Ni–Co alloy coating.