What does it take to unlock an Iphone?

I'm buying an Iphone 4 and am planning on using it on T-mobile but alot of them are locked so how do you unlock them or how much does an unlocking code cost and where do you get it from?

You need a password to unlock them… Passwords are free. Maybe if you buy the iPhone first you can set a password. For free.

Go on ebay pay 5 bucks, send them your imei # and when the person you bought the unlock from tell you its done.restore the iphone with the tmobile sim card in it. Then its factory unlocked!

Well you can just get your iPhone Factory Unlocked from http://www.officialphoneunlock.com and have no worries, no hassles at all.
It's unlocked remotely so there's no problem usually and your iPhone will also be capable to work on other carriers/countries

They just register your IMEI # into Apple's servers so you can unlock with iTunes and your iPhone gets equal to a factory unlocked iPhone.
I recommend because my friend and I got our iPhones unlocked from there

T-Mobile can't Unlock your iPhone 4 instead I recommend you to contact Apple as

"T-Mobile does not recommend getting an unofficially unlocked iPhone (jailbroken), as some services and features may not work on the T-Mobile network. Additionally, software updates on jailbroken devices may re-lock the device."

http://www.apple.com/...t/contact/

You can unlock your Iphone 4 by using Remote unlocking service. You can get this service from http://www.mobile-unlocker.com/apple-iphone-4/rs16wp9/ at affordable cost. Here they are using latest version of iTunes software. So it is safe and secure way to unlock your Iphone 4.