nsurl

iOS - Download file only if modified (NSURL & NSData)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 09:18:17
I am downloading a bunch of image files from a server, and I want to ensure that they are downloaded only if they are newer. This method currently downloads the images just fine. However, I don't want to waste time or energy re-downloading images every time the user logs into the app. Instead, I want to only download any files that A) Don't exist B) Are newer on the server than on the device Here is how I am downloading the images: *The image url is saved in Core Data with the video it is associated to. The url is generated using a simple conversion method I build (generateThumbnailURL) -(void

How to get NSData from file by using PHAsset

馋奶兔 提交于 2019-12-01 08:37:01
I have file at path file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov But when I try this code- NSError *error; NSData *data = [NSData dataWithContentsOfFile:assetUrl.relativePath options:NSDataReadingMappedAlways error:&error]; I got nothing but error: Error Domain=NSCocoaErrorDomain Code=257 "Не удалось завершить операцию. (Cocoa, ошибка 257)" UserInfo=0x175a61380 {NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0197.mov, NSUnderlyingError=0x17424e550 "Не удалось завершить операцию. Operation not permitted"} File exists but I can't read it. But at the same time AVPlayer normally plays video

How to get Remote File Last-Modification Date

筅森魡賤 提交于 2019-12-01 07:07:30
问题 I need to get the file modification date of a remote file. Obviously, attributes in this example returns NULL : - (BOOL) fileHasBeenModifiedSinceLastLaunch { NSError * err = nil; NSDictionary * attributes = [FILEMANAGER attributesOfItemAtPath:[NSURL URLWithString:@"http://www.wrightscs.com/some_file.txt"] error:&err]; NSString * modified = [NSString stringWithFormat:@"%@",[attributes objectForKey:@"NSFileModificationDate"]]; NSString * savedmod = [[NSUserDefaults standardUserDefaults]

iOS - Download file only if modified (NSURL & NSData)

无人久伴 提交于 2019-12-01 07:02:11
问题 I am downloading a bunch of image files from a server, and I want to ensure that they are downloaded only if they are newer. This method currently downloads the images just fine. However, I don't want to waste time or energy re-downloading images every time the user logs into the app. Instead, I want to only download any files that A) Don't exist B) Are newer on the server than on the device Here is how I am downloading the images: *The image url is saved in Core Data with the video it is

How to get NSData from file by using PHAsset

两盒软妹~` 提交于 2019-12-01 06:44:29
问题 I have file at path file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov But when I try this code- NSError *error; NSData *data = [NSData dataWithContentsOfFile:assetUrl.relativePath options:NSDataReadingMappedAlways error:&error]; I got nothing but error: Error Domain=NSCocoaErrorDomain Code=257 "Не удалось завершить операцию. (Cocoa, ошибка 257)" UserInfo=0x175a61380 {NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0197.mov, NSUnderlyingError=0x17424e550 "Не удалось завершить операцию.

NSLog crashes with certain NSURL- iOS 9.2

。_饼干妹妹 提交于 2019-12-01 06:34:26
问题 Here is my code,where the crash occurs:- let URL = NSURL(string: "http://files.parsetfss.com/fa80bc63-88d4-412d-a478-2451cffc92a9/tfss-1d2a321d-b02e-4745-a589-e31536f648df-XXXXX%20CAT15%2030.p0001.jpg") NSLog("Loading page with URL: \(URL)") The app crashes with EXC_BAD_ACCESS 回答1: The first argument of NSLog() is a format string , and contains format specifiers (starting with % ) which are expanded by the following variable argument list. In your case %20C is a format specifier, but no

SWIFT: Why is “NSURL(string:” returning with Nil, even though it's a valid url in a browser?

爷,独闯天下 提交于 2019-12-01 05:50:02
The first two example links are working the third one returns NIL. Why is NSUrl returning nil for such string, even though it's a valid url in a browser? Am I supposed to process the string more? Here is my code: import UIKit import Foundation class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, NSXMLParserDelegate { var myFeed : NSArray = [] var url : NSURL! var feedURL : NSURL! var selectedFeedURL = String() @IBOutlet var tableFeeds: UITableView! @IBOutlet var webView: UIWebView! override func viewDidLoad() { super.viewDidLoad() // Set feed url. //url = NSURL

Swift 3.0 Getting URL of UIImage selected from UIImagePickerController

孤者浪人 提交于 2019-12-01 05:42:46
Note:- This question is only for Swift 3.0 I am able to get the path prio to Swift 3.0 I want to get UIImage's path picked in didFinishPickingMediaWithInfo method let imageUrl = info[UIImagePickerControllerReferenceURL] as? NSURL let imageName = imageUrl.lastPathComponent let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! let photoURL = NSURL(fileURLWithPath: documentDirectory) let localPath = photoURL.appendingPathComponent(imageName!) But this path is not pointing to my image, Even there is no any image in Documents folder. Can

Preview document using UIDocumentInteractionController doesn't work in iOS 13

泄露秘密 提交于 2019-12-01 05:20:30
问题 I use the UIDocumentInteractionController to preview files of different types within the app. This has worked fine in the past, but when running the app on a device with iOS 13 the document is not presented. What is shown is the file name and type. I have looked for similar questions and found this UIDocumentInteractionController showing file name and file type , not file contents I've tried NSUrl.CreateFileUrl(FilePath, null) as the comments on that question suggest but this doesn't solve

Swift 3.0 Getting URL of UIImage selected from UIImagePickerController

泄露秘密 提交于 2019-12-01 02:19:23
问题 Note:- This question is only for Swift 3.0 I am able to get the path prio to Swift 3.0 I want to get UIImage's path picked in didFinishPickingMediaWithInfo method let imageUrl = info[UIImagePickerControllerReferenceURL] as? NSURL let imageName = imageUrl.lastPathComponent let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! let photoURL = NSURL(fileURLWithPath: documentDirectory) let localPath = photoURL.appendingPathComponent(imageName