nsurl

Building up a URL in Objective-C [closed]

随声附和 提交于 2020-01-07 09:16:10
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I want to make a request to diffrent servers I only want to fill in the url or ip address in a textfield. I build different solutions but they all faild.

Referencing a string inside an NSURL

▼魔方 西西 提交于 2020-01-06 14:20:54
问题 I'm trying to use this string inside this NSURL however I don't think its right and in turn giving me an ASI HTTP request failed error. NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://furious-ice-356.heroku.com/places/%@/reviews.xml",self.identifier]]; 回答1: self.identifier returns (in most cases) an object of the type id . You cannot cast this object to a NSString* . The only exception is the in 10.7 newly introduced identifier property of NSString* in the

Memory Leak - NSString & NSURL

三世轮回 提交于 2020-01-05 22:42:09
问题 @property ( nonatomic, strong ) NSURL * urlPath; self.urlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"bark" ofType:@"caf"]]; Running ARC, deployment target 4.3. Instruments gives a leak on the self.urlPath = line. The self.urlPath is used later on after the view has appeared to setup the AVSoundPlayer. There is NO leak indicated now on the soundplayer, only on this NSURL line. The audio plays, but when the view is pop'd a memory leak occurs. Any ideas as I've been at

App crashes up when opening url in safari

℡╲_俬逩灬. 提交于 2020-01-05 12:12:28
问题 I'm trying to open url in safari with this code: - (IBAction)webButton:(id)sender { NSString *url = @"www.google.com"; url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [[UIApplication sharedApplication]openURL:[NSURL URLWithString:url]]; } But every time app crashes up. Has someone been in similar situation? Here is ss off crash: http://dl.dropbox.com/u/77033905/urlInSafariCrashesUp.png UPDATE: NSString *recipients = @"mailto:first@example.com?subject=Hello from

Detecting if a custom file icon was set in Cocoa

半腔热情 提交于 2020-01-05 10:30:58
问题 I wrote an app that sets a custom icon for some files, but as the creation of such an icon is quite expensive I'd like to test if a custom icon was already set before. With custom icon I mean an icon that isn't the default icon set by OS X. In particular, I can have different icons for different files having the same type. I already tried checking [NSURL resourceValuesForKeys:[NSArray arrayWithObjects:NSURLCustomIconKey,NSURLEffectiveIconKey,nil] error:nil] , but the object associated with

Preventing NSURLSession default HTTP headers

狂风中的少年 提交于 2020-01-05 07:44:18
问题 I'm trying to craft a very specific HTTP request to a server (ie. defining the exact set of HTTP headers), but NSURLSession keeps "helpfully" inserting a bunch of HTTP headers like Accept , Accept-Language and Accept-Encoding . Consider the following playground (Swift 2.x) which sends a request to a service that just echos the HTTP headers that were sent: import Foundation import XCPlayground XCPlaygroundPage.currentPage.needsIndefiniteExecution = true let url = NSURL(string: "http://httpbin

coredata problem nsurl may not respond to stringByAppendingPathComponent

丶灬走出姿态 提交于 2020-01-03 15:58:29
问题 I had some problems after starting a new coredata project with the xcode 3.2.5... my previous projects with core data (in previous xcode) worked fine, so I dont know what is the difference?? so the error I get when I build and go to the view that calls the core data is> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter' the strange thing is that in my *AppDelegate.m, in (edited thanks Rog but still not

Security-Scoped Bookmarks for a directory

无人久伴 提交于 2020-01-03 15:36:27
问题 I need to give full read/write permission for a directory where the application write some file to this directory. I read that using sandboxed application it required to Enable Security-Scoped Bookmark and URL Access to access a folder after relaunch the app. So I am trying to implement it based on the code here with some minor modification What is the correct way to handle stale NSURL bookmarks? NSOpenPanel* openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseDirectories:YES]; [openDlg

Why does my NSURL object is equal to nil? My path is correct

▼魔方 西西 提交于 2020-01-03 05:45:06
问题 NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%lf,%lf&output=csv&sensor=false&key=swizzlec hops", coordinate.latitude,coordinate.longitude]; NSLog(@"urlString: %@", urlString); NSURL *urlFromURLString = [NSURL URLWithString:urlString]; My log is : http://maps.google.com/maps/geo?q=53.872874,27.527790&output=csv&sensor=false&key=swizzlec hops I can copy this url and paste to the browser and its ok, but urlFromURLString = nil. But, why? 回答1: I believe you

NSURL max length?

霸气de小男生 提交于 2020-01-03 04:02:12
问题 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? 回答1: 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