nsurl

Url minus query string in Objective-C

余生长醉 提交于 2019-12-01 02:09:32
What's the best way to get an url minus its query string in Objective-C? An example: Input: http://www.example.com/folder/page.htm?param1=value1&param2=value2 Output: http://www.example.com/folder/page.htm Is there a NSURL method to do this that I'm missing? There's no NSURL method I can see. You might try something like: NSURL *newURL = [[NSURL alloc] initWithScheme:[url scheme] host:[url host] path:[url path]]; Testing looks good: #import <Foundation/Foundation.h> int main(int argc, char *argv[]) { NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; NSURL *url = [NSURL URLWithString:@

NSURLErrorDomain error -1021

梦想与她 提交于 2019-12-01 02:03:59
I'm developing an app were I integrated dropbox. Login is done properly also I'm able to create folder in dropBox. But when I try to load file I'm getting error Following error I'm getting error making request to /1/files_put/dropbox/Info.plist - Error Domain=NSURLErrorDomain Code=-1021 "The operation couldn’t be completed. (NSURLErrorDomain error -1021.)" UserInfo=0x6859bc0 {destinationPath=/Info.plist, sourcePath=/Users/bcod/Library/Application Support/iPhone Simulator/5.0/Applications/0E1EE43C-8F6B-40FA-8696-D3992DA2DCE5/DBRoulette.app/Info.plist} I'm not getting this error when I'm

Swift - NSURL error

只谈情不闲聊 提交于 2019-11-30 21:11:54
Getting an error when trying to use the NSURL class below, the code below is essentially trying to store an image I am pulling in from Facebook into an imageView . The error is as follows: value of optional type 'NSURL?' not unwrapped, did you mean to use '!' or '?' Not sure why this is is happening, help! import UIKit class ViewController: UIViewController { @IBOutlet weak var myImage: UIImageView! override func viewDidLoad() { super.viewDidLoad() let myProfilePictureURL = NSURL(string: "http://graph.facebook.com/bobdylan/picture") let imageData = NSData(contentsOfURL: myProfilePictureURL)

UIImagePickerControllerReferenceURL always returns nill

邮差的信 提交于 2019-11-30 20:26:29
I am trying to get the name of the image which I have just captured from camera with following code. But [info objectForKey:@"UIImagePickerControllerReferenceURL"] always returning nil. How can I get the URL? - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { self.myinfo = info; NSLog(@"Dismissing camera ui..."); [self.cameraUI dismissViewControllerAnimated:YES completion:nil]; NSLog(@"Getting media url..."); NSString *mediaURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSLog(@"Media url = %@", mediaURL); NSLog(@

Swift: save video from NSURL to user camera roll

匆匆过客 提交于 2019-11-30 11:26:18
问题 I have a variable videoURL of type NSURL. If I call println(videoURL) it would return something like this: http://files.parsetfss.com/d540f71f-video.mp4 I have a button set up that should take this videoURL and save the video to the user's camera roll. The best I have done is this: UISaveVideoAtPathToSavedPhotosAlbum(videoPath: String!, completionTarget: AnyObject!, completionSelector: Selector, contextInfo: UnsafeMutablePointer<Void>) While I'm not even sure if this will work or not, I can't

How to make an NSURL that contains a | (pipe character)?

☆樱花仙子☆ 提交于 2019-11-30 11:07:09
I am trying to access google maps' forward geocoding service from my iphone app. When i try to make an NSURL from a string with a pipe in it I just get a nil pointer. NSURL *searchURL = [NSURL URLWithString:@"http://maps.google.com/maps/api/geocode/json?address=6th+and+pine&bounds=37.331689,-122.030731|37.331689,-122.030731&sensor=false"]; I dont see any other way in the google api to send bounds coordinates with out a pipe. Any ideas about how I can do this? Have you tried replacing the pipe with %7C (the URL encoded value for the char | )? As stringByAddingPercentEscapesUsingEncoding is

What to do about an NSURLErrorDomain -999? [duplicate]

痞子三分冷 提交于 2019-11-30 09:35:55
Possible Duplicate: How do I fix NSURLErrorDomain error -999 in iPhone 3.0 OS I have an iphone app, built with Jqtouch and phonega,p framework successfully made and submitted to the appstore several times. Then I updated to the new phonegap1.0.0, and then started getting errors related to something called webview. Eventually was advised to create new xcode project and import the old www folder into it. There are now no more errors but the app gets stuck in a loop with the error NSURLErrorDomain error -999. The app loads then starts flashing wildly between screens and the debugger repeats

Getting URL of UIImage from UIImagePickerController

北战南征 提交于 2019-11-30 08:37:46
问题 I'm trying to get the URL of an image imported from Library in Swift to send it to Apple Watch with transferFile(_:metadata) but I'm having two error on NSURL . This is my code: func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) { imagePicked.image = image let imageUrl = editingInfo[UIImagePickerControllerReferenceURL] as! NSURL let imageName = imageUrl.path!.lastPathComponent let documentDirectory =

Launching App Store from App in Swift

南楼画角 提交于 2019-11-30 08:15:30
I am creating an app, and I have a banner which promotes my other app. This is my code: var barsButton : UIButton = UIButton(frame: CGRectMake((self.view.bounds.width / 2) - 51, self.view.bounds.height - 100, 102, 30)) barsButton.setImage(UIImage(named: "Bars Icon 2.png"), forState: .Normal) barsButton.addTarget(self, action: "openBarsLink", forControlEvents: UIControlEvents.TouchUpInside) func openBarsLink() { var barsLink : String = "itms-apps:https://itunes.apple.com/app/bars/id706081574?mt=8" UIApplication.sharedApplication().openURL(NSURL.URLWithString(barsLink)) } However, when the user

NSURL URLWithString:relativeToURL: is clipping relative url

喜欢而已 提交于 2019-11-30 08:04:50
I'm trying to implement an iOS app, which uses RestKit. In all examples I've seen so far the following code is used to create the URLs: NSURL *baseURL = [NSURL URLWithString:@"https://api.service.com/v1"]; NSURL *relativeURL = [NSURL URLWithString:@"/files/search" relativeToURL:baseURL]; But then [relativeURL absoluteString] will return https://api.service.com/files/search . So I tried a few examples: NSURL *baseURL1 = [NSURL URLWithString:@"https://api.service.com/v1/"]; NSURL *baseURL2 = [NSURL URLWithString:@"https://api.service.com/v1"]; NSURL *baseURL3 = [NSURL URLWithString:@"/v1"