SAN FRANCISCO — A year ago, many investors had given up on Apple, whose stock price had fallen more than 30 percent from its 2015 peak.