That's the only way to get a 6IV Ditto without cheating since you can't breed them. If you have a friend safari with a Ditto, you are guaranteed 2 perfect IVs, other than that you have to be lucky.
You could chain them to increase your chances as well, but that would take a bit of skill in chaining too. [Here][1] is a guide on chaining.
And as fondant commented, this has a high chance of breaking before getting to 61, so I wouldn't rely on it. [1]: https://www.smogon.com/ingame/guides/chaining