Let's say I hire someone to build an app on the iPhone and it turned out to be a cash cow. What's stopping the developer from releasing a tweaked version that you paid him to make? Is there some sort of contract the developer has to sign?
The contract between you and the developer is entirely up to you, and you'd be wise to hire yourself a lawyer to draft it if you want it to stick in the event of cash cowdom.
This question is not specific to cellphone apps: it is a standard question of intellectual property and competitiveness. Who owns the code - the funder or the programmer? And can the programmer then compete?
The answer to this is a common business/legal idiom - an IP section in the contract. In most companies, a developer "Signs away" the rights to things developed at the workplace to the employer. He typically also signs away the right to directly compete with the employer, for example by changing the code, or releasing it himself.
Since you are not a full-time employer, you are hiring someone as a "contract employee" - you better have a contract. There are probably different ones available, but they often depend on the jurisdiction you reside in and the jurisdiction in which your programmer is located. You can probably find some contracts online but you may want to consult with a lawyer. If nothing works, at least reach a written signed agreement that can show intent ot the courts if it ever goes there.
If you can't prove that you gave someone money to build something for you and that the person surrendered the rights to you, you're in trouble.
Another thing to consider... If you outsourced that app development to a country that does not acknowledge the intellectual property laws of your country then your contract means nothing. The developer can sign it saying they won't violate them in your country, but they are not a citizen and can't be held to that contract. International law is entirely different ball of wax and requires different (and even higher priced) lawyers.
We got bit by this several years ago. The consulting firm we hired was in the US and signed "normal" contracts. They had people who worked in India. One of them took the code and resold it on a contracting site. The contract was not binding against him because India didn't recognize the IP rights assignment in the original consulting agreement. Our legal time didn't know the international laws around it... It was a BIG MESS.