H&M swings to loss, affirms commitment to China market