  We theoretically study the indirect interaction between two ferromagnetic
contacts located on the surface of a $d$-wave superconductor. When the magnets
are connected to a $\{010\}$ edge of the superconductor we find an oscillating
RKKY interaction that varies in sign as the distance between the magnetic
contacts is varied. However, when coupling the magnets to an $\{110\}$ edge of
the superconductor, we find that the presence of midgap states qualitatively
changes the results. The ground state of the system is then found to always
favor alignment of the magnets as this configuration most strongly suppresses
the midgap states, leading to a larger condensation energy which dominates over
the intrinsic RKKY interaction.
