nsurl

Order a NSURL array

谁说我不能喝 提交于 2019-12-23 01:17:09
问题 I'm loading a lot of image paths into a NSURL. The images are in a folder ordered from 1.PNG, 2.PNG, 3.PNG to 1500.PNG. When I trie to load them: let imagePath = path + "/images" let url = NSURL(fileURLWithPath: imagePath) print(url) let fileManager = NSFileManager.defaultManager() let properties = [NSURLLocalizedLabelKey, NSURLCreationDateKey, NSURLLocalizedTypeDescriptionKey] do { imageURLs = try fileManager.contentsOfDirectoryAtURL(url, includingPropertiesForKeys: properties, options

Create a directory and store files inside it in Swift

自古美人都是妖i 提交于 2019-12-22 10:47:29
问题 i am creating a directory so that i can save temp videos onto it as TempVideos is a folder now my video clips will be inside the folder... func createTempDirectoryToStoreVideos(){ var error: NSError? let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) let documentsDirectory: AnyObject = paths[0] tempVideoPath = documentsDirectory.stringByAppendingPathComponent("TempVideos") if (!NSFileManager.defaultManager()

How can I get the URL from webView in swift

て烟熏妆下的殇ゞ 提交于 2019-12-22 10:26:59
问题 I have question, how can I fetch the url from the webView ? I perform the following code and I get the nil Code I'm trying : override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(true) webView.loadRequest(URLRequest(url: URL(string: "https://www.youtube.com/watch?v=Vv2zJErQt84")!)) if let text = webView.request?.url?.absoluteString{ print(text) } } 回答1: You are not getting url because webView has not finished the loading of that requested URL , you can get that URL in

Proper way to access image in saved photos using NSURL and upload to S3?

只愿长相守 提交于 2019-12-22 09:21:02
问题 I'm using this code to upload an image to S3 AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager]; AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new]; uploadRequest.bucket = @"my-photo-bucket"; uploadRequest.key = @"test_upload"; long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:self.imageUrl.path error:nil][NSFileSize] longLongValue]; uploadRequest.contentLength = [NSNumber

NSURLThumbnailDictionaryKey empty for local file

Deadly 提交于 2019-12-22 08:44:43
问题 I want to get a thumbnail representation of a file I have to display in my app. I'm using NSURL here: NSDictionary *thumbnails = nil; BOOL success = [fileURL getResourceValue:&thumbnails forKey:NSURLThumbnailDictionaryKey error: &error]; This works fine if I am connected to iCloud, and the URL is a link to a file stored in iCloud. The fileURL is something like: file:///Users/me/Library/Mobile%20Documents/BJXXGLR9R3~com~myapp~icloud/FileStorage/contact-page%20copy.png If I use the same code

iOS: Playing video that needs authentication works in QuickLook but not in MPMoviePlayerViewController

自古美人都是妖i 提交于 2019-12-22 04:35:53
问题 I login to my server using a SOAP web service . Once logged in, many of the files that I am viewing are only available to the logged in user, so iOS must create a session in NSURL or something. When trying to preview a video file using MPMoviePlayerViewController it will not work, it just loads up the viewController, then dismisses it. If I use QuickLook it does work, probably because I download the video locally first, then view it. But, I don't want to do it this way, I want to stream the

NSURL's parameterString confusion with use of ';' vs '&'

守給你的承諾、 提交于 2019-12-21 12:58:55
问题 I'd like to use -[NSURL parameterString] to parse out the parameters of a URL I've been passed. It says URL must conform to RFC 1808 but now wondering if ours do?!? We use something like: http://server/path/query?property1=value1&property2=value2 but RFC 1808 never mentions the ampersand ( & ) as a valid parameter separator (at least the way I read it). It suggests the semicolon ( ; ). Perhaps because it was drafted in 1995? Has the & replaced the ; ? If so anyone verify if NSURL's

Created NSURL is null

馋奶兔 提交于 2019-12-21 04:25:50
问题 NSURL printing null . What's the reason? NSString *webStr = [[NSString alloc] initWithFormat:@"%@",[webArray objectAtIndex:1]]; NSLog(@"urlString = %@",webStr); // its printing correct url string NSURL *webURL = [[NSURL alloc] initWithString:webStr]; NSLog(@"url = %@",webURL); // its printing null [webURL release]; [webStr release]; 回答1: You should do the following. NSString *webStr = [[NSString alloc] initWithFormat:@"%@",[webArray objectAtIndex:1]]; NSLog(@"urlString = %@",webStr); // its

How to take the parameter from URL scheme.

白昼怎懂夜的黑 提交于 2019-12-20 17:29:21
问题 I am using URL scheme in my iPhone app,from a page I switch user to safari,and a button click from Web page,I am reverting back to app At that time ,some parameters are passed by the web page like myapp://parameter=1 How can I find this parameter from my app ? I have placed a break point in -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)ur but while revert back.it is not get called. 回答1: You can use this url host to find out the parameters, where parameters could be of

What is the Swift 3 equivalent of NSURL.URLByAppendingPathComponent()?

拜拜、爱过 提交于 2019-12-20 16:31:31
问题 I'm following a basic tutorial on building a simple iOS app in Swift. It is written in Swift 2.x, and I work with XCode 8 Beta and Swift 3. The tutorial suggests using NSFileManager to find a data directory. Class names have changed, so the auto-fixed Swift 3 looks like this: static let DocumentsDirectory = FileManager().urlsForDirectory(.documentDirectory, inDomains:.userDomainMask).first! static let ArchiveURL = DocumentsDirectory.URLByAppendingPathComponent("meals") However, Xcode now