nsurl

MPMoviePlayerController doesn't play from Documents folder

怎甘沉沦 提交于 2019-12-03 16:21:47
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: NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"Oct_08_2012_10_00_51" withExtension:@"mp4"];

File access in a sandboxed Mac app with swift

时光总嘲笑我的痴心妄想 提交于 2019-12-03 12:53:20
问题 I am working on an app for OS X 10.9 with swift, sandboxed. The app needs access to a SQLite database file. I let the user choose/open a file with NSOpenPanel. I then save the file path with NSUserDefaults for later use. I want this file to be opened automatically every time when the app is started again. I get the stored path from the NSUserDefault, but when I open the file with this path I get an error, saying I have no permission to access the file. (it is working without sandboxing) It

Created NSURL is null

馋奶兔 提交于 2019-12-03 12:25:27
NSURL printing null . What's the reason? NSString *webStr = [[NSString alloc] initWithFormat:@"%@",[webArray objectAtIndex:1]]; NSLog(@"urlString = %@",webStr); // its printing correct url string NSURL *webURL = [[NSURL alloc] initWithString:webStr]; NSLog(@"url = %@",webURL); // its printing null [webURL release]; [webStr release]; You should do the following. NSString *webStr = [[NSString alloc] initWithFormat:@"%@",[webArray objectAtIndex:1]]; NSLog(@"urlString = %@",webStr); // its printing correct url string NSURL *webURL = [[NSURL alloc] initWithString:[webStr

encoding url using swift code

时间秒杀一切 提交于 2019-12-03 10:13:22
I need to send an URL in Arabic language, so I need to encode it before I put it in URL. I am using Swift code. Below is an example what i really need var s = "www.example.com/السلام عليكم" let url = NSURL(string : s) So the word (السلام عليكم) is in Arabic characters that what I want to send. yarlg Swift 2.0 let urlwithPercentEscapes = myurlstring.stringByAddingPercentEncodingWithAllowedCharacters( NSCharacterSet.URLQueryAllowedCharacterSet()) Swift 3 let urlwithPercentEscapes = myurlstring.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed) Vyacheslav To improve @Druva's answer

Can I create an NSURL that refers to in-memory NSData?

给你一囗甜甜゛ 提交于 2019-12-03 06:38:20
问题 The docs for NSURL state that: An NSURL object represents a URL that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data . I have a blob of in-memory data that I'd like to hand to a library that wants to load a resource via an NSURL . Sure, I can first write this NSData to a temp file and then create a file:// NSURL from that, but I'd prefer to have the URL point directly to the buffer that I

NSURL baseURL returns nil. Any other way to get the actual base URL

走远了吗. 提交于 2019-12-03 06:05:39
I think I don't understand the concept of "baseURL". This: NSLog(@"BASE URL: %@ %@", [NSURL URLWithString:@"http://www.google.es"], [[NSURL URLWithString:@"http://www.google.es"] baseURL]); Prints this: BASE URL: http://www.google.es (null) And of course, in the Apple docs I read this: Return Value The base URL of the receiver. If the receiver is an absolute URL, returns nil. I'd like to get from this example URL: https://www.google.es/search?q=uiviewcontroller&aq=f&oq=uiviewcontroller&sourceid=chrome&ie=UTF-8 This base URL https://www.google.es My question is simple. Is there any cleaner way

Get resource URL from project specific path

我怕爱的太早我们不能终老 提交于 2019-12-03 05:53:14
I need to retrieve the URL of a resource contained in my Xcode project through a path that begins in the project's directory (aka mainBundle) So if my specified path if ./snd/archer/acknowledge1.wav, I need to create a URL from that. I know I can use NSURL(fileURLWithPath:) for system directories, but I don't know how to do this directly from the bundle. Wain You would use one of the bundle resourse URL methods [[NSBundle mainBundle] URLForResource:@"acknowledge1" withExtension:@"wav" subdirectory:@"snd/archer"]; NSBundle.mainBundle().URLForResource("acknowledge1", withExtension:"wav"

iPhone - NSData from local file's URL

梦想的初衷 提交于 2019-12-03 04:05:00
问题 I have a NSURL object which gives me the path of a local file (in documents folder). I want to populate an NSData object with the contents of this file. Tried using dataWithContentsOfURL: but this fails. I know the file exists because the iPhone SDK returns the path. Can someone please tell me how I can get an NSData object from the URL of a local file? Thanks. 回答1: // Given some file path URL: NSURL *pathURL // Note: [pathURL isFileURL] must return YES NSString *path = [pathURL path]; NSData

How to take the parameter from URL scheme.

微笑、不失礼 提交于 2019-12-03 03:58:34
I am using URL scheme in my iPhone app,from a page I switch user to safari,and a button click from Web page,I am reverting back to app At that time ,some parameters are passed by the web page like myapp://parameter=1 How can I find this parameter from my app ? I have placed a break point in -(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)ur but while revert back.it is not get called. You can use this url host to find out the parameters, where parameters could be of any kind, anything after http:// or custom tag custom:// will be caught in the following code NSString

File access in a sandboxed Mac app with swift

ぐ巨炮叔叔 提交于 2019-12-03 03:10:47
I am working on an app for OS X 10.9 with swift, sandboxed. The app needs access to a SQLite database file. I let the user choose/open a file with NSOpenPanel. I then save the file path with NSUserDefaults for later use. I want this file to be opened automatically every time when the app is started again. I get the stored path from the NSUserDefault, but when I open the file with this path I get an error, saying I have no permission to access the file. (it is working without sandboxing) It looks like bookmark's are the solution to my problem. Is there a good tutorial how to use bookmark's with