Powered by sales of its iPhone X, the tech giant reported another strong quarter and defied fears that consumers wouldn’t buy the pricey devices.