nsurl

Downloading a large file in iOS app

筅森魡賤 提交于 2020-01-02 07:33:15
问题 I'm trying to clean up some existing code that downloads a large file from a server in chunks, checks the checksum on each 50 packets, then stitches them together. I'm having some trouble to see if it's the most efficient way as right now it crashes some time because of memory issues. If I don't have the checksum, it does not seem to crash, but I would prefer if I could check my files first. @property (nonatomic, retain) NSMutableData * ReceivedData; - (void)connectionDidFinishLoading:

URLWithString returns nil for resource path - iphone

我怕爱的太早我们不能终老 提交于 2020-01-01 09:24:12
问题 Having a problem getting the URL for a resource for some reason: This code is in viewDidLoad, and it's worked in other applications, but not here for some reason: NSString* audioString = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"]; NSLog(@"AUDIO STRING: %@" , audioString); NSURL* audioURL = [NSURL URLWithString:audioString]; NSLog(@"AUDIO URL: %d" , audioURL); NSError* playererror; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&playererror];

NSURL isFileURL always returns NO

心已入冬 提交于 2020-01-01 04:20:27
问题 Can someone explain to me why the following code: NSString* filePathString = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSLog(@"%i", [[NSURL URLWithString:filePathString] isFileURL]); NSLog(@"%@", filePathString); outputs: 0 "/var/mobile/Applications/28ADFC19-874C-4304-94B5-F6441CAE9FAD/Documents" This means that this url isn't a file URL. Obviously, it is. Background: I'm trying to use an AVCaptureMovieFileOutput to write a movie recording to a file,

What are the current kernel resource limits on security-scoped bookmarks?

前提是你 提交于 2020-01-01 03:29:31
问题 The docs for -[NSURL startAccessingSecurityScopedResource] state: You must balance every call to the startAccessingSecurityScopedResource method with a corresponding call to the stopAccessingSecurityScopedResource method. If you fail to relinquish your access when you no longer need a file-system resource, your app leaks kernel resources. If sufficient kernel resources are leaked, your app loses its ability to add file-system locations to its sandbox, such as via Powerbox or security-scoped

Swift - Playing Videos from iOS PHAsset

社会主义新天地 提交于 2019-12-31 12:35:12
问题 I want to play video from PHAsset , collected from iOS Photos. PHAsset video nsurl (https://stackoverflow.com/a/35099857/1084174) is valid to my own application lets say MyPlayer for few moments/blocks. When I am copying the image/video into MyPlayers own sandbox only then the nsurl becomes always valid. It seems to me, I need to copy each video from temporary PHAsset nsurl to MyPlayers sandbox (appgroup/documents) and only then I can play the video with sandbox relative nsurl. If this is the

NSURL returning nil for certain cases

无人久伴 提交于 2019-12-31 03:57:24
问题 I'm creating an NSURL to send as a request to a PHP rest API that I've got setup. Here's my code below: NSMutableString *url = [NSMutableString stringWithFormat:@"http://www.private.com/recievedata.php?item=%@&contact=%@&discovery=%@&summary=%@",__item,__contactDetails,__lostFound,__explain]; //The " ' " in PHP is a special character, so we have to escape it in the URL //The two slashes are because the "\" itself is a special character in Objective C NSString *formattedURL = [url

Issue with encoding “&” in URLs

半腔热情 提交于 2019-12-31 01:22:50
问题 I've got to send a https GET request to a web service in my iPhone app which is developing in Swift 1.2. I am trying to construct query string parameters but got to encode them before send to server. All good but not working when password contains '&' charcter. Expect to encode '&' character to '%26' but NOT working... Just done a test when having '%'. Works as expected with '%' providing '%25'. But NOT convert '&' sign.... Tried following ways: var testPassword1: String = "mypassword&1" var

ios URL(string: ) not working always

允我心安 提交于 2019-12-30 19:59:02
问题 let testurl = "http://akns- images.eonline.com/eol_images/Entire_Site/2018029/rs_1024x759- 180129200032-1024.lupita-nyongo-angela-bassett-black-panther- premiere.ct.012918.jpg?fit=inside|900:auto" if let url = URL(string: testurl){ print("valid") }else { print("invalid") } This prints as an invalid URL. But shows the image in web browser. I have seen lot of methods but it throws Apple warning to use stringByAddingPercentEncodingWithAllowedCharacters and this doesn't work always. I would

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

旧街凉风 提交于 2019-12-30 09:37:23
问题 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

vertical pipe symbol not being detected in NSURL

回眸只為那壹抹淺笑 提交于 2019-12-30 04:46:24
问题 I'm trying to place a search in google dictionary but the url contains a vertical pipe/bar | My code just fails to load the site //http://www.google.com/dictionary?aq=f&langpair=en|en&q=test+test+test&hl=en if ([mySearchEngineName isEqualToString:@"Google Dictionary"]){ NSLog(@"Currently searching %@ using %@", mySearchString, mySearchEngineName); NSString *mutateSearchString = [mySearchString stringByReplacingOccurrencesOfString:@" " withString:@"+"]; NSString *searchURL =[NSString