TORONTO -- Apple Inc.'s Tim Cook visited Canada for the first time as CEO Monday, surprising students at a downtown Toronto Apple store to highlight the importance of learning to code, and dropping in on a group of developers to thank them for their contributions to the tech giant's app store.

The unannounced visit by Cook, who as Apple's chief executive since 2011 has overseen the rollout of the iPhone 7 and the Apple Watch, was the first time an Apple CEO has visited Canada since Steve Jobs made the trek north in the late 1980s.

Cook surprised a class of Grade 7 students in Toronto's east end as they learned how to program robots to dance on tables using Apple's Swift programming language, recently introduced by the company as a low-barrier-to-entry way of coding.

"Swift came out of the fundamental recognition that coding languages were too geeky. Most students would look at them and say, 'that's not for me," Cook said as the pre-teens participated in an Apple-designed "Everyone Can Code" workshop, which helps children learn how to build mobile apps, at the Apple Store in Toronto's Eaton Centre.

"That's not our view. Our view is that coding is a horizontal skill like your native languages or mathematics, so we wanted to design a programming language that is as easy to learn as our products are to use."

There are 250,000 apps in the App Store that have been coded with Swift, including popular ones such as LinkedIn and AirBnb. In 2016, Apple released Swift Playgrounds, which turns learning the programming language into a game for people of all ages -- though especially for students.

The Canadian visit follows a similar surprise last week, when Cook visited a school in the United Kingdom, as part of a whistle-stop tour of Europe, where Apple recently launched its "Everyone Can Code" curriculum in several schools.

The CEO's tour to promote the benefits of Apple technology comes after the company recently came under fire from shareholders over concerns about the addictive effects of gadgets and social media on young people.

New York-based Jana Partners LLC and the California State Teachers' Retirement System said in a Jan. 6 open letter to Apple that the company must offer more choices and tools to help children fight addiction to its devices.

Among their proposals to Apple: Establish a committee of experts, including child development specialists; offer Apple's "vast information resources" to researchers; and enhance mobile device software so that parents have more options to protect their children's health.

But Cook's Canadian stop in was squarely focused on the benefits, both educational and economic, of Apple's technology.

There are more than 120,000 jobs in Canada directly related to Apple's iOS and App Store ecosystem, the company said Monday. These positions can include developers, designers, entrepreneurs and other highly skilled roles.

"Canada is an extremely important market for us. We have a great team in Canada," Cook said.

"I want to do everything I can do to highlight their innovation, their companies and their work, because it is a critical part of the entire user experience. I wanted to come say thank you."

Demand for digital skills in Canada continues to expand and the federal government has identified coding as a key job development skill. By 2021, there will be 210,000 Canadian jobs in the space and, based on forecasted numbers of computer science graduates, the country won't have the skilled workers to fill these positions.

Denise Salsman, who teaches the Grade 7 class that Cook surprised, said that in less than a year of implementing code into the classroom, her students have seen an improvement in their grades.

"Coding is something my students, who will have jobs we don't even know about yet, need to know."

Cook's visit came the same day the federal government launched its first major investment in coding education.

Navdeep Bains, Federal Minister of Innovation, Science and Economic Development introduced CanCode, a federal program designed to help Canadian students improve their digital skills.

"It's a $50 million program launched by our government to pave the path for Canada's future leaders," Bains said at a stop at Microsoft Canada in Mississauga, Ont.

Bains said the program will give more than one million children and their teachers across Canada the chance to develop their digital skills.