Being a shareholder of Apple (AAPL -0.11%) hasn't been easy over the last year. The stock has risen 5% since last May, which is abnormal for a company that regularly outperforms the S&P 500 (which grew 25% in the same period).

Spikes in inflation in 2023 caused reductions in consumer spending, leading Apple to post four consecutive quarters of revenue declines.

However, the company appears to be turning things around in 2024. After missing earnings estimates for all of last year, revenue aligned with forecasts in the first quarter of 2024 and beat them in the second quarter.

Apple still has a lot of work ahead as it restructures to depend less on iPhone sales over the long term and expands in artificial intelligence (AI). But the company's significant cash reserves and nearly unrivaled brand loyalty suggest its shares remain an attractive investment for patient stockholders.

So, here's why it's not too late to buy Apple stock.

Beating expectations alongside the biggest stock buyback in its history

Shares in Apple have climbed 5% since the company released its second-quarter 2024 earnings on May 2. During the quarter, revenue dipped 4% year over year to $91 billion, yet beat analyst forecasts by $190 million. Earnings per share came in at $1.53 against expectations of $1.50.

Its iPhone business took another hit in the quarter, with sales falling 10%. The company said COVID-related supply strains during the previous year saw Apple realize $5 billion in delayed iPhone 14 sales. CEO Tim Cook said, "If you remove that $5 billion from last year's results, we would have grown this quarter on a year-over-year basis."

The bright spot of the quarter came from the company's second-highest earning segment, services. The digital business includes income from the App Store and its various subscription services, with revenue increasing by 14% year over year.

But the recent rally was primarily thanks to news that Apple plans to buy back $110 billion in shares, the largest amount in its history. The figure beats last year's $90 billion buyback and will see its dividend increase by $0.01.

Apple still has a mountain to climb to regain consistent quarterly growth, but the buyback plan is a vote of confidence from management in the company's financial future.

The company remains a leader in consumer tech, achieving $102 billion in free cash flow in the second quarter despite recent headwinds. That figure indicates it has the funds to continue investing in its business and overcome current challenges.

Future products will place a more significant focus on AI

Apple made headlines again this week after its Let Loose product event, where the company introduced a new iPad Air, iPad Pro, and the Apple Pencil Pro.

The new devices signaled a shift in Apple's product lineup, with its new iPad Pro equipped with what the company describes as an "outrageously powerful chip for AI." It has dubbed the new chip the M4, released just months after launching its M3 chip in new Macs last October.

Demand for artificial intelligence services and AI-capable devices has skyrocketed since last year. The company has been slightly late to the AI party, while Microsoft and Amazon have dominated the space with their respective cloud platforms. However, as a leader in consumer tech, Apple has the unique opportunity to become the go-to choice for businesses and consumers seeking AI-enabled products.

The immense brand loyalty from its users has allowed Apple to achieve leading market shares in smartphones, tablets, headphones, and smartwatches. As a result, expanding its AI capabilities could make the company a major growth driver in the public's adoption of the technology.

The iPad announcement comes after news broke in April that Apple had acquired Datakalab, a Paris-based start-up specializing in on-device AI tools. Last month, Bloomberg also reported that Apple plans to overhaul its Mac lineup to prioritize AI offerings.

The AI market is expanding rapidly and is projected to have a compound annual growth rate of 37% through 2030. If Apple can leverage its brand power to dominate the product segment of AI, the company could enjoy a significant boost in earnings in the coming years.

AMZN PE Ratio (Forward) Chart

Data by YCharts; PE = price to earnings.

Moreover, Apple is one of the best-value AI stocks compared to Microsoft and Amazon. This chart shows the iPhone company has a significantly lower forward price-to-earnings ratio and price-to-free cash flow, indicating its stock is trading at bargain compared to these tech giants.

It will take time for the company to turn things around, but it's not too late to invest in Apple. Its expanding services business and growing position in AI make its stock worth considering for a long-term hold.