nsurl

CFURLCreateDataAndPropertiesFromResource failed with error code -15

心不动则不痛 提交于 2019-12-25 03:16:52
问题 I'm trying to lead a TIFF image into a CGImageSource using CGImageSourceCreateWithURL. My URL is correct, is %20 encoded, is a path to an existing file, that file is a TIFF. However, the line: NSString *fullPath = [[[fileNames objectAtIndex:pageNum - 1] string] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSString* urlStr = [NSString stringWithFormat: @"file:/%@", fullPath]; NSURL * url = [NSURL URLWithString: fullPath]; CGImageSourceRef src = CGImageSourceCreateWithURL

NSUTF8StringEncoding gives me this %0A%20%20%20%20%22http://example.com/example.jpg%22%0A

谁说我不能喝 提交于 2019-12-25 01:49:39
问题 I'm trying to load pictures from twitter. If i just use the URL in the json results without encoding, in the dataWithContentsOfURL , I get nil URL argument. If I encode it, I get as follow's %0A%20%20%20%20%22http://example.com/example.jpg%22%0A. I know I can use rangeOfString: or stringByReplacingOccurrencesOfString: but can I be sure that it will always be the same, is there another way to handle this, and why is this happening to my twitter response and not my instagram response? I have

Objective C write to Remote URL

怎甘沉沦 提交于 2019-12-25 01:49:34
问题 Ok, so I have the correct username / pass for a remote host, and I have a NSURL Object referring to the file on the server. How can I possibly write data to that server via Objective-C? I cannot find anyone with this problem, so you help would be greatly appreciated! 回答1: I do it all the time with the program I am writing. The answer depends on what server you have installed and what languages it supports. If, as I think, you have PHP, just send a GET request to your server and instruct the

NSURL _fastCStringContents:Some link URL giving error when trying to open from inside iOS app

孤人 提交于 2019-12-25 01:17:30
问题 I am trying to open link in Safari browser from inside my iOS app. Its a hybrid app so I made changes in iOS native side (which I am totally unfamiliar with) I have tried this code from below posts: Open target="_blank" links outside of UIWebView in Safari NSLog(@"open safari"); // NSLog(urlSafari); // [[UIApplication sharedApplication] openURL:urlSafari]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[request.URL.absoluteString substringFromIndex:7]]]; //[NSURL

Upload file to FTP server with Swift

余生颓废 提交于 2019-12-24 15:48:41
问题 I'm using a framework RebekkaTouch to upload files from my Swift app to an FTP server, just like: if let URL = NSBundle.mainBundle().URLForResource("myFile", withExtension: "txt") { let path = "myFile.txt" session.upload(URL, path: path) { (result, error) -> Void in print("result:\n\(result), error: \(error)\n\n") } } This works great for files I manually upload via Xcode. But I don't seem to be able to find the file path for file I download and store locally on the Documents directory

How to handle redirecting urls with get parameters in the request?

戏子无情 提交于 2019-12-23 21:30:45
问题 I am trying to get an html response from a server(aspx). NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.someSiteThatRedirectsWithGetParameters.com?parameter1=1&parameter2=2"]; NSURL *url = [ NSURL URLWithString:urlstr]; NSMutableURLRequest *urlRequest = [ NSURLRequest requestWithURL: url]; NSData data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; NSURL *lastURL=[response URL]; NSLog(@"Last url %@", lastURL); I am getting

Get image width and height before loading it completely in iPhone

丶灬走出姿态 提交于 2019-12-23 12:15:10
问题 I am loading an image in my UITableViewCell using [NSData dataWithContentsOfURL:imageUrl] For setting custom height for my tableview cell , i need the actual size of the image that am loading. Can we get the width and height of an image before loading it completely ? Thanks in advance. 回答1: NSData is an "opaque" data, so you cannot do much with it before converting it to something more "useful" (e.g., creating an UIImage by means of it -initWithData: method). At that moment you could enquiry

NSUrl is not stored as absolutestring in NSUserDefault

孤街浪徒 提交于 2019-12-23 09:09:10
问题 I am referring Previous Post for storing NSURL of iPod Library in NSUserDefault. But it is not stored in NSUserDefault after application is closed. I am using other NSStrings to store in NSUserDefaults which is perfectly done, But when i store NSUrl as absolute string.. it does not stores the value. What could be the reason?? EDIT Following code i am using to save NSUserDefault Value: currentItem = [collection.items objectAtIndex:songCount]; songURL = [currentItem valueForProperty

How to URL encode a NSString

我是研究僧i 提交于 2019-12-23 08:56:41
问题 I am trying to url encode a string, but the NSURLConnection is failing because of a 'bad url'. Here is my URL: NSString *address = mp.streetAddress; NSString *encodedAddress = [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *cityState= mp.cityState; NSString *encodedCityState = [cityState stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *fullAddressURL = [NSString stringWithFormat:@"http://www.zillow.com/webservice

issue in encoding a string with percent escaping iphone

旧巷老猫 提交于 2019-12-23 06:29:16
问题 This is my string. NSString *str=@"A & B"; now i am converting it to NSUTF8StringEncoding. str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"str: %@", str); space is replaced with %20 but & is not replaced with %26. nslog show str: A%20&%20B This is also not working NSString *str=@"(A) & (B)"; str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"str: %@", str); nslog show str: (A)%20&%20(B) I need this because i have to pass