So in a few other place on stack overflow and online I see this code:
func postImage2() {
var instagramURL = NSURL(string: "instagram://app")
if(UIApplication.sharedApplication().canOpenURL(instagramURL!)) {
var imagePost = image
var fullPath = documentsDirectory().stringByAppendingPathComponent("insta.igo")
var imageData = UIImagePNGRepresentation(imagePost).writeToFile(fullPath, atomically: true)
var rect = CGRectMake(0, 0, 0, 0)
self.docController.UTI = "com.instagram.exclusivegram"
var igImageHookFile = NSURL(string: "file://\(fullPath)")
self.docController = UIDocumentInteractionController(URL: igImageHookFile!)
self.docController.annotation = ["InstagramCaption":"Text"]
self.docController.presentOpenInMenuFromRect(rect, inView: self.view, animated: true)
} else {
print("no instagram found")
}
}
However, this gives a complaint: stringByAppendingPathComponent is unavailable. UseURLByAppendingPathComponent on NSURL instead. I have heard this is a new initiative that apple is trying to get people to move from string based paths to urls.
In any case, how can I update this code so that it works with URLByAppendingPathComponent?