Xcode 7.0: iOS Action Extension template does not work (image is not shown in extension)
| Originator: | aralbalkan | ||
| Number: | rdar://22755302 | Date Originated: | 18-Sep-2015 12:32 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 7.0 (7A218) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
There is a bug in the action extension template (it assumes that an image will be found when an NSURL is returned). This means that the image in the sample is not populated. This is confusing for developers who expect Xcode template code to run correctly.
Steps to Reproduce:
1. File -> New Target… -> iOS -> Application Extension -> Action Extension
2. Run it and select a photo (e.g., from Photos app)
Expected Results:
The photo should display in the UIImageView in the ActionViewController
Actual Results:
The photo does not display.
The error is at:
itemProvider.loadItemForTypeIdentifier(kUTTypeImage as String, options: nil, completionHandler: { (image, error) in
NSOperationQueue.mainQueue().addOperationWithBlock {
if let strongImageView = weakImageView {
strongImageView.image = image as? UIImage
}
}
})
Sample correct code:
itemProvider.loadItemForTypeIdentifier(kUTTypeImage as String, options: nil, completionHandler: { (imageURL, error) in
NSOperationQueue.mainQueue().addOperationWithBlock {
if let strongImageView = weakImageView
{
if let imageURL = imageURL as? NSURL
{
strongImageView.image = UIImage(data: NSData(contentsOfURL: imageURL)!)
}
}
}
})
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!