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


  • 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":
« Last Edit: August 20, 2015, 02:48:14 AM by kjmcneish »