Author Topic: How do I add resources to a playground?  (Read 2297 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
How do I add resources to a playground?
« on: December 16, 2014, 11:27:05 AM »
You can add resources to a playground as follows:

  • Launch Finder and navigate to the playground file.
  • Right-click the playground file and select Show Package Contents from the popup menu.
  • If a Resources folder doesn't already exist, create one.
  • Add resources (such as images) to the Resources folder.

Now your playground contains resources that you can reference from the playground. For example, if you added an imaged named IaoNeedle.jpg to the resources folder, you can reference it like this:

Code: [Select]
var img = UIImage(named: "IaoNeedle.jpg")
All the best!
Kevin McNeish
Author of "Learn to Code in Swift": https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
« Last Edit: August 20, 2015, 02:48:14 AM by kjmcneish »