nsurl

Strange Invisible Character in String causing NSURL to fail

孤者浪人 提交于 2020-01-17 07:12:08
问题 I am having a String to Number problem that is taking me days to resolve. So it all started out in my app that involves taking a phone number from the addressbook and making a call. Everything was working fine until I noticed some phone numbers were causing my program to crash. After some time, I finally figured that they were crashing for the phone numbers that had a space in it, which finally made sense because even though it is a phone number I am using NSURL to call "tel://(555) 555 5555"

Pass username and password in URL for authentication

☆樱花仙子☆ 提交于 2020-01-17 05:15:09
问题 I want ot pass username and password in URL(web service) for user authentication which will return true and false.I'm doing this as following: NSString *userName = [NSString stringWithFormat:@"parameterUser=%@",txtUserName]; NSString *passWord = [NSString stringWithFormat:@"parameterPass=%@",txtPassword]; NSData *getUserData = [userName dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *getUserLength = [NSString stringWithFormat:@"%d",[getUserData length]]; NSData

Show UIActivityIndicatorView when loading NSString from Web

人盡茶涼 提交于 2020-01-17 03:17:22
问题 Hi in my app I load a NSString from Internet using NSURL, and then a label shows the text. If i press the button to load the String, it becomes highlighted and stays highlighted for a couple of seconds. During that time i want a UIActivityIndicatorView to show up, to inform the user that the app is actually doing something. Ive tried just adding [activity startAnimating]; to the IBAction but it only starts animating when the button is back to the default state, not when its highlighted. ive

Display UIAlertView before opening phone.app

一世执手 提交于 2020-01-16 16:57:18
问题 I have a view on map with a button and a label on the button. On the label i have phone number that comes from a plist. The variable of the phone number in the plist called "storePhone" and i implemented it in this way: text4.text = myAnn.storePhone; I made this method for pressing the button and opening the phone.app for dialing the number. Everything works great but i want a UIViewAlert to say to the user something like:"your going to dial this number, are you sure?" before the phone.app is

Display UIAlertView before opening phone.app

ⅰ亾dé卋堺 提交于 2020-01-16 16:57:05
问题 I have a view on map with a button and a label on the button. On the label i have phone number that comes from a plist. The variable of the phone number in the plist called "storePhone" and i implemented it in this way: text4.text = myAnn.storePhone; I made this method for pressing the button and opening the phone.app for dialing the number. Everything works great but i want a UIViewAlert to say to the user something like:"your going to dial this number, are you sure?" before the phone.app is

URL host comparison

£可爱£侵袭症+ 提交于 2020-01-16 11:20:07
问题 Here I am trying to compare the hosts of 2 URLs. Even though that hosts are the same it does not respond why! Code: NSURL *url=[NSURL URLWithString:@"http://www.facebook.com/"?ref=logo" ]; NSURL *domain=[ NSURL URLWithString:@"http://www.facebook.com" ]; if ( [url host]==[domain host] ) { NSLog(@"hosts are matched"); }else { NSLog(@"hosts are not matched!"); } 回答1: You need to use isEqualToString: NSURL *url=[NSURL URLWithString:@"http://www.facebook.com/?ref=logo" ]; NSURL *domain=[ NSURL

NSURLRequest with url containing special characters

核能气质少年 提交于 2020-01-16 05:35:29
问题 I'm having the same problem as: NSURL with special characters But tried their solution. Can't get my NSURLRequest to work with åöä characters. If the variable "string" contains åöä the request return null. Also tried with NSISOLatin1StringEncoding. NSString *encodedString = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat: @"http://suggestqueries.google.com/complete/search?output=firefox&q=%@", encodedString]; NSURL *url

Posting picture from iphone to facebook wall

99封情书 提交于 2020-01-13 07:01:08
问题 I'm using Facebook Connect for iOS to post a picture, taken in an app, to facebook wall, possible using the local file URL, according to another post: adding photo on facebook wall The URL appears to be pointing somewhere valid, but the picture doesn't show up. Verified that it does work with a web link. Anyone have an idea why this isn't working for local files? Would I need permissions beyond regular wall posts? Help! 回答1: According to facebook, any image posted to a stream has to be web

“NSURL” is not implicitly convertible to “URL”; did you mean to use “as” to explicitly convert?

女生的网名这么多〃 提交于 2020-01-12 06:42:07
问题 I have latest xcode beta, just trying to load a webpage inside an app. import UIKit class ViewController: UIViewController { @IBOutlet var webView: UIWebView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let url = NSURL (string: "https://www.google.com"); let requestObj = NSURLRequest(URL: url!); webView.loadRequest(requestObj); } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose

A solution to track a batch of HTTP requests in swift 3.0

百般思念 提交于 2020-01-11 13:19:07
问题 I am using swift 3.0 running under iOS 10.0 and I want to craft some code that fires when a batch condition is met. for i in 0 ..< rex { async code, disappears and does it stuff } Imagine the async code is a collection of URL requests, that basically background as soon as I loop thru them. Now how can I fire off more code when "rex" requests have completed? I thought of setting up a timer to watch and check every second, but its surely not a good solution. I thought kicking off another thread