A former Iranian official was released in Sweden in exchange for a European Union diplomat and a second Swede.