nsurl

Press a Button and open a URL in another ViewController

旧时模样 提交于 2019-12-12 04:45:43
问题 I am trying to learn Xcode by making a simple app. But I been looking on the net for hours (days) and I cant figure it out how I make a button that open a UIWebView in another ViewController :S first let me show you some code that I have ready: I have a few Buttons om my main Storyboard that each are title some country codes like UK, CA and DK. When I press one of those Buttons I have an IBAction like this: - (IBAction)ButtonPressed:(UIButton *)sender { // Google button pressed NSURL* allURLS

iOS download file from a URL that will redirect to the file

不想你离开。 提交于 2019-12-12 02:55:57
问题 I've been trying for 2 days and cant figure this out. Basically I have a URL and I try to download the file that associate with it using ASIHTTPRequest, but the URL I have is not the link of the file itself, but that URL will redirect to the link of the actual file. I try to give that link to ASIHTTPRequest for download, but it didn't. SO I think I have to somehow get the redirected url and feed that to ASIHTTPRequest to download the file. How can I do this? Thanks all for reading :) 回答1: You

How to pass an array in an url query parameter using nsurl in objective-c?

不打扰是莪最后的温柔 提交于 2019-12-12 02:51:59
问题 The API need to pass an array in an url query parameter, how to acheive this in iOS? I only know how to pass a single vaue, like the API below : ?title=Design Milk&id=feed/http://feeds.feedburner.com/design-milk API sample: "title": "Design Milk", "id": "feed/http://feeds.feedburner.com/design-milk", "categories": [ { "id": "user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/design", "label": "design" }, { "id": "user/c805fcbf-3acf-4302-a97e-d82f9d7c897f/category/weekly", "label": "weekly" },

NSURL problems in Swift

笑着哭i 提交于 2019-12-12 02:27:14
问题 I'm building a weather app and this whole block of code is an error. I've tried almost everything. This is the code: func getCurrentWeatherData() -> Void { let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/") let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL) let sharedSession = NSURLSession.sharedSession() let downloadTask: NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(forecastURL!, completionHandler: { (location: NSURL!, response

How to upload an array to a WebService

…衆ロ難τιáo~ 提交于 2019-12-12 02:25:35
问题 I'm having some doubts about how to upload something to a WebService. I've been using this for getting info from my webservice: NSString * URLString = [NSString stringWithFormat:@"%@%@", kBaseHost, [NSString stringWithFormat:kWSProjectList, token]]; NSURL *url = [NSURL URLWithString:URLString]; NSURLRequest * request = [NSURLRequest requestWithURL:url]; [NSURLConnection sendSynchronousRequest:request inBackgroundWithCompletionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

Nothing displayed after splitting a list of image URLs

a 夏天 提交于 2019-12-12 01:12:28
问题 I have six image URLs in a string named aux . I split it with component separated by newlines. I want to pick images one by one from aux and display each in an ImageView . My code is: aux = [_homeText.text stringByAppendingString:[NSString stringWithFormat:@" %@ ",item.shortDescription]]; [_homeText setText:aux]; NSString *list =aux; NSArray *listItems = [list componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]; [listItems count]; if ([listItems objectAtIndex:0]) {

How can I deal with connection problem when I use NSData?

南楼画角 提交于 2019-12-11 23:48:34
问题 One init method of NSXMLParser is initWithData:(NSData *data). When I init the NSData like this, NSURL *url = [NSURL URLWithString:@"http://221.34.21.9"]; NSData *date = [[NSData alloc] initWithContentsOfURL:url]; if the IP address cannot be reached, my app will wait for that address's response forever. How can I solve this problem? Thanks! 回答1: You will have to get the data through a NSURLConnection , which will have a timeout value, as described in the URL Loading System Programming Guide.

iOS no communication between iPhone app and MySQL database via PHP

蹲街弑〆低调 提交于 2019-12-11 23:43:58
问题 I need help trying to figure out why my iPhone app is not communicating with my PHP. I have a text field where the user can enter a message and there is a button that is supposed to tell the app when the text has been entered and needs to be posted to my mySQL database. My PHP and iOS code are pasted below, but I also included some debugging statements here. I put a break at the line if([serverOutput...) and at that point I get the following: alertsuccess UIAlertView * 0x00000000 dataURL

Is it possible to just get the domain and TLD from an NSURL? No www or anything else?

巧了我就是萌 提交于 2019-12-11 23:26:41
问题 Say I have http://www.youtube.com , http://youtube.com , and https://www1.youtube.com/moretext . How would I write a check to see if all of those URLs are from youtube.com? I tried url.host and it seems to keep the www. and whatnot, which is not what I want. I basically just want to be able to say: if ([url isFromWebsite:@"youtube.com"]) { // Do things. } Is this possible? 回答1: Here’s an untested category on NSURL that will provide the method you want. @implementation NSURL (IsFromWebsite) -

Handle screens based on Custom URL Scheme using UIStoryBoard

纵然是瞬间 提交于 2019-12-11 20:29:20
问题 I have two applications named with, SendDataApp ReceiveDataApp This is my StoryBoard of ReceiveDataApp I can able to send data to my receiving app and can handle it by below method, - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options; But, here the problem is i want to show the data which i received from SendDataApp to my DetailViewController of ReceivedDataApp I am trying with below method to handle it, Appdelegate.m - (BOOL