Apple posts record revenue despite slowing iPhone sales