nsurl

NSURLSession delegate methods not called

浪尽此生 提交于 2019-12-05 13:23:51
I have created a very simple app to download a text file from my web server. I have this working perfectly with NSURLConnection, but am trying to migrate over to NSURLSession instead. The issue I am having is that none of the delegate methods are being called. My server is password protected so I need to use the basic http authentication to access the file, but when the didReceiveChallenge method is never called. The line of code [getFileTask resume] seems to have no effect on anything. My setup is as follows: @interface ViewController : UIViewController <NSURLSessionDelegate,

containerURLForSecurityApplicationGroupIdentifier getting nil value

不问归期 提交于 2019-12-05 10:11:06
I am making two iPad app that communicate with one file and fetches all the data from one file. I search and find this "containerURLForSecurityApplicationGroupIdentifier" we can create group and store in that. I have write the code below. In entitlement file i write <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>com.apple.security.app-sandbox</key> <true/> <key>com.apple.security.application-groups</key> <array> <string>$(TeamIdentifierPrefix)com.xxx.catalogapp

Storing an NSURL as a string in Core Data

99封情书 提交于 2019-12-05 08:51:24
I'm beginning to play around with Core Data and just have a question around storing something like a URL. I've currently got it configured as a transformable which is working fine however I feel that it's probably storing excess data unnecessarily and since it can be easily represented with text I'm wondering whether I should just be storing the absolute URL as a string and instantiating an NSURL object when it's loaded (I suspect this is the case) and if so how should this be implemented? My research so far leads me to think maybe use mogenerator and then just override the property accessors

Retrieve filename from NSURL

不羁岁月 提交于 2019-12-05 08:45:15
问题 I have a URL http://www.hdwallpapers.in/walls/honda_v4_concept_widescreen_bike-wide.jpg I want to extract the file name which is "honda_v4_concept_widescreen_bike-wide.jpg" How can I can do this? 回答1: The code below should work. Updated it so I removed the top statement. I could've used NSString vs const char * or std::string from C++ but thought C Character Pointers would be quite appropriate for this case in point. Also revamped this so it's in it's own concise function: -(NSString*)

AppleWatch Messages URL works hard coded but not with variables

帅比萌擦擦* 提交于 2019-12-05 07:30:36
TLDR When I hard code phone numbers into a URL it opens in watch messages correctly, but when I use a variable string with the numbers typed in exactly the same way inside of it, it doesn't. Example: NSURL(string: "sms:/open?addresses=8888888888,9999999999,3333333333&body=Test") Above code works but below code doesn't: let hardCode = "8888888888,9999999999,3333333333" NSURL(string: "sms:/open?addresses=\(hardCode)&body=Test") FULL DETAILS: I am making a URL from variables to open messages on the Apple Watch with pre-filled contents. I am getting the phone numbers from the contact book and

iPhone - Save URL without setURL:forKey: and NSURL

无人久伴 提交于 2019-12-05 04:48:38
问题 Is there anyway to save a URL with NSUserDefaults without setURL:forKey: that is only available to iOS 4.0 and later? I am loading HTML files locally with fileURLWithPath, and it starts at an intro page and the user can click through to whatever. For now, everytime a user starts over it loads back default to intro.htm. I would like to be able to save their current page to NSUserDefaults on viewdiddissapear and reload it next time, but can't find any solutions besides setURL:forKey:. Anyone

MPMoviePlayerController doesn't play from Documents folder

Deadly 提交于 2019-12-05 02:00:07
问题 Desperated. Hello everybody! I am having some issues with MPMoviePlayerController. I've made it working with videos from NSBundle. But that's not what I need. I need to play it from Documents directory, because that is the place I store the recorded videos, wich URLs are stored in CoreData. but lets leave this aside, and simplify the code to its minimum needed. This code actually WORKS if using the contentURL, wich leads to NSBundle. After it, what I do to get to the docs place. What I do:

Deep link in to iOS Settings' Notifications page?

霸气de小男生 提交于 2019-12-05 01:58:48
I know that I can deep link into the Settings page on iOS via UIApplicationOpenSettingsURLString . However, this takes me to a page such as this: Now if I want the user to enable notifications, they have to find Notifications in the list and then enable it. Is there a way to instead directly link them to the Notifications page? (i.e. Going to the same exact page as though they had tapped notifications in the screenshot above.) If not, is there a way to take them to the global notifications iOS Settings page? (See screenshot below for an example) No, there is no way to go to any other page in

iOS download sqlite database and replace existing one

人走茶凉 提交于 2019-12-04 22:55:53
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]; NSLog(@"SourcePath path: %@", sourcePath); NSError *error; NSData *data=[NSData dataWithContentsOfURL: