1

Is there any kind of restriction when accessing image through widgets extension? I have an image within Widget extension Supporting Files group called pocket.png

I want to use this image through by Widget custom view controller and as usual i wrote this code

var pocketImage:UIImage = UIImage(named: "pocket")

To my surprise this code returns blank. Tried with pocket.png same problem.

Now i tried to do with image with path and even the below code returns nil

let pathx = NSBundle.mainBundle().pathForResource("pocket", ofType: "png")

So how do i access local available image? Note: The same code works fine when i use it in the main application with its local image.

KD.
  • 2,015
  • 3
  • 28
  • 59
  • See my SO question on using Asset Catalog images in both the app and extension http://stackoverflow.com/questions/25963059/how-to-dislay-an-image-from-asset-catalog-in-today-extension – Andrew Davis Oct 16 '14 at 16:20
  • You should use image in the same target only.Make sure you are not accessing the image from your main target. –  Oct 28 '14 at 05:13

1 Answers1

1

There was an issue with xcode which didn't copy the images properly. I had to delete and copy them again to fix the issue.

KD.
  • 2,015
  • 3
  • 28
  • 59