Spanish telecoms company Telefonica has signed an agreement with Apple to sell the iPhone in Spain this year.