nsurl

NSURL max length?

喜夏-厌秋 提交于 2019-12-06 16:07:40
I need to pass text string up to 20Kb (one NSURLQueryItem value) from one iOS app to another using schemes. I was able to pass not such long URL between the apps. What is max NSURL length supported? Does it depend on iOS version? Is there any better approach to send text long string? NSURL can easily handle 20Kb. The implementation limitation is around 2Gb ( INT_MAX ) for the URL string. The limitations you'll run into first with large URLs are memory and time. You'll run out of memory for the allocations at some point (For 32-bit executables, the limitation is a little over 1.1GB when your

How to get NSURL on specific file from document directory in swift

半城伤御伤魂 提交于 2019-12-06 15:53:47
问题 I getting files from document directory with the help of NSFileManager . I got an array of file names and I can pass them to another controller. Still I want to pass NSURL on specific file from my UITableViewCell as I pass names of these files. My files are mp3. Please help me. var listOfMP3Files: Array<String!>? // for Cell data func fetchFilesFromFolder() { var fileManager = NSFileManager.defaultManager() var folderPathURL = fileManager.URLsForDirectory(NSSearchPathDirectory

iOS download sqlite database and replace existing one

爱⌒轻易说出口 提交于 2019-12-06 14:58:33
问题 I have to download the database and replace existing one in the sandbox: Here's is the presumable way to do that: DBHelpers *help=[[DBHelpers alloc] init]; NSString *targetPath=[[help DocumentsDirectory] stringByAppendingPathComponent:DATABASE_NAME]; NSLog(@"Target path: %@", targetPath); NSFileManager *fileManager=[NSFileManager defaultManager]; //if([fileManager fileExistsAtPath:targetPath]) //{ // NSLog(@"Exists"); // return; } NSString *sourcePath=[help PathForResource:DATABASE_NAME];

Copy image from assets-library to an app folder

≡放荡痞女 提交于 2019-12-06 14:15:55
I have an UIImagePickerController and I would like to save a selected image to my app. I can do that easy by getting the current UIImage and save it (by creating a file) but I would prefer to directly copy the file from Library to my folder. So now I have an URL of the selected image : UIImagePickerControllerReferenceURL which return a specific pattern "assets-library". I tried to copy an image from this kind of URL to a path but without success. Is there a way to success on what I would like to do ? Thanks ! Shamsudheen TK You can do it through two ways First Way: Using imagePickerController

mySQL database to iPhone app

纵然是瞬间 提交于 2019-12-06 12:52:42
问题 I have a MySQL database on a web server and need to read the data from an iPhone app. What is the best way to do this? The data needs to be accessed from the web server and will be updated from time to time. Is the NSURL Class the way to go? thanks for any help. 回答1: I suggest a simple web technology on the server side -- PHP, Ruby on Rails, etc. -- that acts as a basic RESTful-ish web service that sends out JSON. This is straightforward and doesn't require a lot of programming expertise --

Order a NSURL array

你离开我真会死。 提交于 2019-12-06 11:18:01
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:NSDirectoryEnumerationOptions.SkipsHiddenFiles) } catch let error1 as NSError { print(error1.description) }

+[NSURL URLWithString:] returning nil

北城余情 提交于 2019-12-06 09:46:55
I use this code to load a UIImage from a URL : NSURL *imageURL = [NSURL URLWithString:@"http://testwebsite.com/image.png"]; NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageURL]; imageView.image = [UIImage imageWithData: imageData]; but I'm stuck at a URL that looks like this one : http://www.testwebsite.com/getFile?userID=123 this works fine in the browser but returns nil in the imageData variable above. how can I load the image from such an obscured URL (i.e. from a URL that does not show off the file name but rather redirects to the image file) ? thank you in advance. for some

how to post array of images in multipart http post request

限于喜欢 提交于 2019-12-06 08:33:22
I want to upload array of images, how should I append array to NSMutableData . here is my code func createBodyWithParametersMulti(parameters: [String: String]?, filePathKey: String?, imageDataKey: [NSData?], boundary: String) -> NSData { let body = NSMutableData(); if parameters != nil { for (key, value) in parameters! { body.appendString("--\(boundary)\r\n") body.appendString("Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n") body.appendString("\(value)\r\n") } } if(imageDataKey.count != 0){ let filename=filePathKey as! String // let mimetype = "image/jpeg" body.appendString("--\

NSURLConnection and NSMutableURLRequest Authentication

余生颓废 提交于 2019-12-06 07:31:57
I have an iOS application which will submit a username and password to a website and to retrieve the HTML code of the webpage which loads after pressing 'Sign in': https://grades.bsd405.org/Pinnacle/Gradebook/Logon.aspx ?. The form data fields are the following: __LASTFOCUS, __EVENTTARGET, __EVENTARGUMENT, __VIEWSTATE, __EVENTVALIDATION, ctl00$ContentPlaceHolder$Username, ctl00$ContentPlaceHolder$Password, ctl00$ContentPlaceHolder$lstDomains, ctl00$ContentPlaceHolder$LogonButton, PageUniqueId This is the code that I have so far: NSURL * url = [NSURL URLWithString:@" https://grades.bsd405.org

NSURL with special characters (åäö)

末鹿安然 提交于 2019-12-06 05:26:15
I have some images on my server, named with special characters (å,ä,ö). I can't figure out how to convert the NSUrl to get them: NSString *urlString = [NSString stringWithFormat: @".../Images/%@Image.png", playerName]; NSURL *url = [NSURL URLWithString: [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSLog(@"url:%@", url); //Get the image and assign it to the player NSData *imageData = [NSData dataWithContentsOfURL:url]; UIImage *image = [UIImage imageWithData:imageData]; The log in the above example (if "playerName" = åäö): .../Images/%C3%A5%C3%A4%C3%B6Image.png