nsurl

How can I build a URL with query parameters containing multiple values for the same key in Swift?

纵然是瞬间 提交于 2019-12-29 04:27:08
问题 I am using AFNetworking in my iOS app and for all the GET requests it makes, I build the url from a base URL and than add parameters using NSDictionary Key-Value pairs. The problem is that I need same key for different values. Here is an example of what I need the finally URL to look like - http://example.com/.....&id=21212&id=21212&id=33232 It's not possible in NSDictionary to have different values in same keys. So I tried NSSet but did not work. let productIDSet: Set = [prodIDArray] let

Swift parsing attribute name for given elementName

一曲冷凌霜 提交于 2019-12-29 02:10:42
问题 Here is a part of my URL <cities> <country name="Абхазия"> <city id="37188" region="27028" head="" type="3" country="Абхазия" part="" resort="" climate="">Новый Афон</city> <city id="37178" region="10282" head="" type="3" country="Абхазия" part="" resort="" climate="">Пицунда</city> <city id="37187" region="37187" head="" type="3" country="Абхазия" part="" resort="" climate="">Гудаута</city> <city id="37172" region="10280" head="" type="3" country="Абхазия" part="" resort="" climate="">Гагра<

Reliable way to compare two NSURL or one NSURL and an NSString?

让人想犯罪 __ 提交于 2019-12-28 11:47:06
问题 I recently had a problem when comparing two NSURLs and compare one NSURL with an NSString(which is a URL address), the situation is I got an NSURLRequest from somewhere, I may or may not know the URL address it points to, and I have an URL NSString, say "http://m.google.com", now I need to check if the URL in that NSURLRequest is the same as the URL string I had: [[request.URL.absoluteString lowercaseString] isEqualToString: [self.myAddress lowercaseString]]; this returns NO as the

Convert String to NSURL is return nil in swift

左心房为你撑大大i 提交于 2019-12-28 02:50:06
问题 I am trying to convert a String to NSURL and my code for that is Below: var url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=\(self.latitude),\(self.longitude)&destinations=\(self.stringForDistance)&language=en-US" println("This is String: \(url)") var remoteUrl : NSURL? = NSURL(string: url) println("This is URL: \(remoteUrl)") And console prints something like this: This is String: https://maps.googleapis.com/maps/api/distancematrix/json?origins=-34.4232722,150.8865837

openURL: deprecated in iOS 10

自古美人都是妖i 提交于 2019-12-28 02:49:28
问题 Apple with iOS 10 has deprecated openURL: for openURL:option:completionHandler If I have: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"]]; How it will become? options:<#(nonnull NSDictionary *)#> in detail [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"] options:<#(nonnull NSDictionary<NSString *,id> *)#> completionHandler:nil]; Thanks Update options:@{} For empty dictionary with no key and value http:/

How to call HTML file with css, js and images?

断了今生、忘了曾经 提交于 2019-12-25 18:53:35
问题 I am downloading zip file from server. In NSCachesDirectory I have the html file and I would like to know how to run html file with their source files, I have pasted my code. please help me NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *documentsPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"/Lesson-file/Lesson%d",[str_lsn_id integerValue]]]; NSURL *url = [NSURL fileURLWithPath:[[NSBundle

Convert NSData from local NSURL

南楼画角 提交于 2019-12-25 12:07:33
问题 I have a sound player which uses AVAudioPlayer class. I download some items in another view and store the filepath to it as NSURL, then pass the NSURL to the Player viewcontroller. But i get an error while trying to pass the object. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString path]: unrecognized selector sent to instance 0x1700c86c0' And here is the code: NSData *data = [NSData dataWithContentsOfFile:[podcastSource path]]; NSError *error

AVPlayer playerWithURL not working after app restart

给你一囗甜甜゛ 提交于 2019-12-25 08:48:19
问题 I am picking a video from the user photo library and than I save the video in the user Documents Folder to be able to play the video even if the user deletes this video from his photo Library. The URL to this file is stored in Core Data. Everything works fine until the next time I run the App. Somehow it seems like the URL is no longer valid, which is strange because I am able to delete the video file when [AVPlayer playerWithURL:videoURL] fails. Here is how I pick the video URL: - (void)

How to retrieve nested file with FileManager?

╄→尐↘猪︶ㄣ 提交于 2019-12-25 07:49:06
问题 In my app, I create this folder structure as soon as the app launches for the first time: I read here Can I save the keep the absolute path of a file in database? - that I should not store the absolute path to a directory or file. Therefore I am having trouble getting reference to the last file shown in the picture above called I-Want-This-File-Path . I could get access up to the Feed folder in the picture above like so: extension FileManager { /// APPLICATION SUPPORT DIRECTORY static func

Loading and Playing Audio with avaudioplayer, UITableView NSURL

我们两清 提交于 2019-12-25 05:20:16
问题 I have a table view of audio objects, each with a url property. I'm looking for the fastest way (for the user) to play each audio file on touch. I tried getting the data first from the url: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSURL *audioURL = [NSURL URLWithString:(NSString *)[[[self.objects objectAtIndex:indexPath.row] objectForKey:@"audioFile"] url]]; NSData *audioData = [NSData dataWithContentsOfURL:audioURL]; NSError *error; self