Search Results

Search found 175 results on 7 pages for 'nsurlrequest'.

Page 3/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • UIWebView doesn't load some link

    - by elos
    hello I'm trying to write an rss feed viewer for my iPhone. In my DetailView I have a UIWebView where I want to display specific link retrieved with the rss item.: NSString* url = [data objectForKey:@"link"]; NSString *encodedUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding ]; NSLog(@"Selected link:%@",url); NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:encodedUrl]]; [itemWebpage loadRequest:request]; [request release]; now,if the retrieved link is something like www.shazaam.com it works. But as soon as the link is something like: http://www.shazam.com/music/web/track?id=41970148" it doesn't. I suppose it's because of the parameter...but how can I fix the problem???? thanks a lot! elos

    Read the article

  • Press a Button and open a URL in another ViewController

    - by Dennis Borup Jakobsen
    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; if([sender.titleLabel.text isEqualToString:@"DK"]) { // Create URL obj allURLS = [NSURL URLWithString:@"http://google.dk"]; }else if([sender.titleLabel.text isEqualToString:@"US"]) { allURLS = [NSURL URLWithString:@"http://google.com"]; }else if([sender.titleLabel.text isEqualToString:@"CA"]) { allURLS = [NSURL URLWithString:@"http://google.ca"]; } NSURLRequest* req = [NSURLRequest requestWithURL:allURLS]; [myWebView loadRequest:req]; } How do I make this open UIWebview on my other Viewcontroller named myWebView? please help a lost man :D

    Read the article

  • problem with opening link through safari with webview

    - by Desmond
    hi i had encounter a problem opening a web link through safari. this is my code header #import <UIKit/UIKit.h> @interface qrcode_info : UIViewController <UIWebViewDelegate,UIAlertViewDelegate> { } @property (nonatomic, retain) IBOutlet UIWebView *Web; @end //main file #import "qrcode_info.h" @implementation qrcode_info @synthesize Web; -(BOOL)Web:(UIWebView *)Web shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked) { [[UIApplication sharedApplication] openURL:[request URL]]; return NO; } return YES; } //[[UIApplication sharedApplication] openURL:[inRequest URL]]; //return NO; - (void)viewDidLoad { [super viewDidLoad]; [Web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"help" ofType:@"html"] isDirectory:NO]]]; //self.wvTutorial = [[WebViewController alloc] initWithNibName:@”WebView” bundle:[NSBundle mainBundle]]; }

    Read the article

  • Trying to trigger php script, get EXC_BAD_ACCESS iPhone development

    - by Brennan Kastner
    This below is my code, when it gets to the end of the function, the debugger throws an EXC_BAD_ACCESS error and when I check the website's logs, the url was never visited. If anyone could help me fix this issue, it would be greatly appreciated: -(IBAction)submitEmail:(id)sender { NSString *urlStringRaw = [[NSString alloc] init]; urlStringRaw = [NSString stringWithFormat:@"http://vedev.org/AnonMail/sendEmail.php?from=%@&to=%@&subject=%@&body=%@", from.text, to.text, subject.text, bodyContent.text]; NSString *urlString = [urlStringRaw stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [urlStringRaw release]; NSURL * url = [NSURL URLWithString:urlString]; [urlString release]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [url release]; NSURLConnection *connection = [NSURLConnection connectionWithRequest:requestObj delegate:nil]; [connection release]; [requestObj release]; }

    Read the article

  • NSMutableRequest skd problem

    - by user2164
    Hi, I am trying to make a web call with the iPhone. I have done this before and it works fine but now I can't make it work. I am trying to use the following method call which the documentation says is availble in 2.0 and later: - (void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field; I am attempting to build for version 3.2 and 4.0. NSMutableURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; [request addValue:@"0" forHTTPHeaderField:@"Content-Length"]; The error that I'm getting is a runtime error that says "-[NSURLRequest addValue:forHTTPHeaderField:]: unrecognized selector sent to instance 0x600e0c0" Can anyone tell me what I am missing that stops this code from working? Thanks.

    Read the article

  • WebUIView is very slow

    - by Shamil
    Hello, I'm building a custom RSS reader app with incorporated feed link view (UIWebView). Using the following code, when the view, containing WebUIView is loaded, it takes about 6 seconds before anything is outputted to the user: -(void)viewDidLoad{ [super viewDidLoad]; NSString *urlString = [[[self appDelegate] currentlySelectedBlogItem]linkUrl]; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [_webview loadRequest:requestObj]; [_webview setScalesPageToFit:YES]; } Any ideas why UIWebView is being so slow? I've checked the URL input, it's clean and what I'd expect it to be. I'm building for iOS 3.0 as base deployment target.

    Read the article

  • UIWebview isn't displaying content I want it to display

    - by Knodel
    In my app I have a UIWebView which loads different rtf files. I use this function to load these files: - (void)loadFile:(NSString*)file { NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file]; NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; } The UIWebView displays nothing. When I enter the debugger, the file string value is which I need, but resourcePath and sourceFilePath values are "nil". What am I doing wrong? Thanks in advance!

    Read the article

  • Sending a message from Objective-C and getting the return value?

    - by Nick Brooks
    I have this code NSString *tr = [self sendUrl:@"http://google.com/"]; But for some reason 'tr' will remain nil after it is executed. What am I doing wrong? sendUrl : - (NSString *)sendUrl:(NSString *) uri { NSLog(@"Requesting URI 1 ..."); // Prepare URL request to download statuses from Twitter NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:uri]]; NSLog(@"Requesting URI 2 ..."); // Perform request and get JSON back as a NSData object NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSLog(@"Requesting URI 3 ..."); // Get JSON as a NSString from NSData response NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; NSLog(@"Requesting URI 4 ..."); return json_string; }

    Read the article

  • WebView not responding when called from a method

    - by AragornSG
    I have an app with tabbar and webview. I'm trying to make the app come back to default url each time user taps the bar. Right now I'm intercepting taps and launching a method, however it's not affecting my webview. The same syntax for calling webview from awakeFromNib works, so I don't have a clue what's up. I suspect it's something to do with how I call the method, but I don't know what. Here is the code: #import "SecondViewController.h" @implementation SecondViewController - (void)awakeFromNib { NSString *loadURL = [NSString stringWithFormat:@"http://pageurl"]; // [secondView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:loadURL]]]; SecondViewController *ptr = [[SecondViewController alloc] init]; [ptr goToPage]; } - (void) goToPage { NSLog(@"go to page"); NSString *newURL = [NSString stringWithFormat:@"http://pageurl"]; [secondView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:newURL]]]; } Thanks fot your help!

    Read the article

  • Send data to server with GET

    - by coderjoe
    I have made a site where all my highscores from my game are shown. I send the scores from my iphone game to my site using a script made with php. The script works, because if I enter the link produced by my app in my browser the score is added. However I want to send the scores from my app. The script is using the GET method to get name, scores etcetera. This is what i have now: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]; NSError * e; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&e]; But it's not sending data to my server. The urlString is correct, because if I enter the link produced by my app in my browser the score is added. How can i solve this problem, Thanks in advance

    Read the article

  • UIWebView in full screen hides status bar

    - by iPhone
    I am opening video in UIWebView with following code. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSLog(@"Navigatin Type %d %@",navigationType, request); if (navigationType == 0) { self.navigationItem.leftBarButtonItem = backBarBtn; [self showVideoInWebView:[request.URL absoluteString]]; return NO; } return YES; } -(void)showVideoInWebView:(NSString *)urlStr { [mainWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]]; } but when my mainWebView opens in full screen it hides my status bar. I don't want to hide status bar then how can I show my status bar?

    Read the article

  • UIWebView load remote html page with local images and javascript files

    - by BlueNile
    Im creating application that will display remote page on the UIWebView using local images and javascript/css files for faster loading. I want to avoid using cache because for this to work it must first load all the content. I was searching online for possible solution. Here is what I have: NSURLRequest *urlrequest = [ [NSURLRequest alloc] initWithURL: [NSURL URLWithString:urlString] ]; NSData *returnData = [ NSURLConnection sendSynchronousRequest:urlrequest returningResponse: nil error: nil ]; NSString *HTMLData = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"]; resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; [webView loadHTMLString:HTMLData baseURL: [NSURL URLWithString: [NSString stringWithFormat:@"file:/%@//",resourcePath] ]]; urlString is defined and I moved files to the app bundle. Code works as I can see the remote page but no images nor javascript files are present.

    Read the article

  • Iphone: controlling text with delay problem with UIWebView

    - by James B.
    Hi, I've opted to use UIWebView so I can control the layout of text I've got contained in a local html document in my bundle. I want the text to display within a UIWebView I've got contained within my view. So the text isn't the whole view, just part of it. Everything runs fine, but when the web page loads I get a blank screen for a second before the text appears. This looks really bad. can anyone give me an example of how to stop this happening? I'm assuming I have to somehow hide the web view until it has fully loaded? Could someone one tell me how to do this? At the moment I'm calling my code through the viewDidLoad like this: [myUIWebView loadRequest: [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"localwebpage" ofType:@"html"] isDirectory:NO]]]; Any help is much appreciated. I've read round a few forums and not seen a good answer to this question, and it seems like it recurs a lot as an issue for beginners like myself. Thanks for taking the time to read this post! UPDATED info Thanks for your response. The suggestions below solves the problem but creates a new one for me as now when my view loads it is totally hidden until I click on my toggle switch. to understand this it's maybe most helpful if I post all my code. Before this though let me explain the setup of my view. I've got a standard view within which I've also got two web views, one on top of the other. each web view contains different text with different styling. the user flicks between views using a toggle switch, which hides/reveals the web views. I'm using the web views because I want to control the style/layout of the text. Below is my full .m code, I can't figure out where it's going wrong. My web views are called oxford & harvard I'm sure its something to do with how/when I'm hiding/revealing views. I've played around with this but can't seem to get it right. Maybe my approach is wrong. A bit of advice ironing this out would be really appreciated: @implementation ReferenceViewController @synthesize oxford; @synthesize harvard; // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; [oxford loadRequest: [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Oxford" ofType:@"html"] isDirectory:NO]]]; [harvard loadRequest: [NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Harvard" ofType:@"html"] isDirectory:NO]]]; [oxford setHidden:YES]; [harvard setHidden:YES]; } - (void)webViewDidFinishLoad:(UIWebView *)webView { if([webView hidden]) { [oxford setHidden:NO]; [harvard setHidden:NO]; } } //Toggle controls for toggle switch in UIView to swap between webviews - (IBAction)toggleControls:(id)sender { if ([sender selectedSegmentIndex] == kSwitchesSegmentIndex) { oxford.hidden = NO; harvard.hidden = YES; } else { oxford.hidden = YES; harvard.hidden = NO; } } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; [oxford release]; [harvard release]; } @end

    Read the article

  • Parsing nested JSON objects with JSON Framework for Objective-C

    - by Sheehan Alam
    I have the following JSON object: { "response": { "status": 200 }, "messages": [ { "message": { "user": "value" "pass": "value", "url": "value" } ] } } I am using JSON-Framework (also tried JSON Touch) to parse through this and create a dictionary. I want to access the "message" block and pull out the "user", "pass" and "url" values. In Obj-C I have the following code: // Create new SBJSON parser object SBJSON *parser = [[SBJSON alloc] init]; // Prepare URL request to download statuses from Twitter NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; // Perform request and get JSON back as a NSData object NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; // Get JSON as a NSString from NSData response NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; //Print contents of json-string NSArray *statuses = [parser objectWithString:json_string error:nil]; NSLog(@"Array Contents: %@", [statuses valueForKey:@"messages"]); NSLog(@"Array Count: %d", [statuses count]); NSDictionary *results = [json_string JSONValue]; NSArray *tweets = [[results objectForKey:@"messages"] objectForKey:@"message"]; for (NSDictionary *tweet in tweets) { NSString *url = [tweet objectForKey:@"url"]; NSLog(@"url is: %@",url); } I can pull out "messages" and see all of the "message" blocks, but I am unable to parse deeper and pull out the "user", "pass", and "url".

    Read the article

  • Objective-C SSL Synchronous Connection

    - by Mike
    Hello, I'm a little new to objective-C but have run across a problem that I can't solve, mostly because I'm not sure I am implementing the solution correctly. I am trying to connect using a Synchronous Connection to a https site with a self-signed certificate. I am getting the Error Domain=NSURLErrorDomain Code=-1202 "untrusted server certificate" Error that I have seen some solutions to on this forum. The solution i found was to add: - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; } to the NSURLDelegate to accept all certificates. When I connect to the site using just a: NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://examplesite.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; It works fine and I see the challenge being accepted. However when I try to connect using the synchronous connection I still get the error and I don't see the challenge functions being called when I put in logging. How can I get the synchronous connection to use the challenge methods? Is it something to do with the delegate:self part of the URLConnection? I also have logging for sending/receiving data within the NSURLDelegate that is called by my connection function but not by the synchronous function. What I am using for the synchronous part: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@"https://examplesite.com/"]]; [request setHTTPMethod: @"POST"]; [request setHTTPBody: [[NSString stringWithString:@"username=mike"] dataUsingEncoding: NSUTF8StringEncoding]]; dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSLog(@"%@", error); stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding]; NSLog(@"%@", stringReply); [stringReply release]; NSLog(@"Done"); Like I mentioned I'm a little new to objective C so be kind :) Thanks for any help. Mike

    Read the article

  • Calculating File size before download - Downloading NSURLConnection Slider timing

    - by sagar
    Ok ! Coming to the point directly. What I want to do is explained as follows. I have an url of MP3 file. ( for example Sound File ) Now, When user starts application. Download should start & for that I have implemented following methods. -(void)viewDidLoad { [super viewDidLoad]; NSURL *url=[NSURL URLWithString:@"http://xyz.pqr.com/abc.mp3"]; NSURLRequest *req=[NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:120]; NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES]; if(con){ myWebData=[[NSMutableData data] retain]; } else { // [MainHandler performSelector:@selector(targetSelector:) withObject:nil]; } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"%@",@"connection established"); [myWebData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@",@"connection receiving data"); [myWebData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"%@",@"connection failed"); [connection release]; // [AlertViewHandler showAlertWithErrorMessage:@"Sorry, there is no network connection. Please check your network and try again."]; // [self parserDidEndDocument:nil]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } Now, Above methods work perfectly for downloading. But missing points are as follows. I can not get the exact size which is going to be downloaded. ( means I want to know what is the size of file - which is going to be download )

    Read the article

  • How load WebView with another URL when navigated through tab bar viewController

    - by TechFusion
    Hello, I have created window based application, root controller as Tab bar controller. WebView is being loaded in Tab bar interfaced ViewController's View.WebView is created using IB.WebView object declared in ViewController as per below. //ViewController.h @interface ViewController:UIViewController{ IBOutlet UIWebview *Webview; } @property(nonatomic,retain)IBOutlet UIWebview *Webview; @end I am calling [WebView loadrequest] method in -viewDidLoad method and stopLoading will be called in -viewWillDisappear method. I am again reload it in -viewWillAppear:animated method to load it again when tab bar is pressed. //ViewController.m @implementation viewcontroller @synthesize Webview; -(void)viewDidLoad{ [super viewDidLoad]; [self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.apple.com"]]]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.Webview reload]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [self.Webview stopLoading]; } I am releasing WebView in -ViewDidUnload method -(void)viewDidUnload{ [super viewDidUnload]; [Webview release]; } -(void)dealloc{ [Webview release]; [super dealloc]; } Does Webview released correctly ? Here how to kill connection with URL when ViewWillDisappear method called ? How to load View with Different URL then it's loaded in -viewDidLoad method when ViewController interfaced tab is pressed ? Means if naviagated from one tab to another that ViewController interface tab which has WebView should load request with another URL. Does it correct to call [self.Webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"www.stackoverflow.com"]]]; this method again in -viewWillAppear:animated method to load with another URL ? Thanks,

    Read the article

  • UIWebView not loading URL when URL is passed from UITableView

    - by Mark Hazlett
    Hey Everyone, So i'm building a webView into my application to show the contents of a URL that I am passing from a selection in a UITableView. I know the UIWebView is loading content properly because if you hard code say http://www.google.ca into the NSURL then it loads fine, however when I'm passing the URL that I parsed from an RSS feed back from the UITableView it won't load the URL properly. I tried the debugger and the URL is coming out as nil right before I try and parse it, however I can use NSLog to print the value of it out to the console. here's the code in my UIViewController that has my UIWebView #import <UIKit/UIKit.h> @interface ReadFeedWebViewController : UIViewController { NSString *urlToGet; IBOutlet UIWebView *webView; } @property(nonatomic, retain) IBOutlet UIWebView *webView; @property(nonatomic, retain) NSString *urlToGet; @end Here's the code for my implementation's viewDidLoad method... // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Url inside Web View Controller - %@", urlToGet); NSURL *url = [NSURL URLWithString:urlToGet]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:requestObj]; } Once again, I can print the URL to NSLog fine and if I hard code the URL into the NSURL object then it will load fine in the UIWebView. Here is where I'm setting the value in my UITableViewController... - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ReadFeedWebViewController *extendedView = [[ReadFeedWebViewController alloc] init]; int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1]; extendedView.urlToGet = [[stories objectAtIndex: storyIndex] objectForKey:@"link"]; //NSLog([[stories objectAtIndex: storyIndex] objectForKey:@"summary"]); NSLog([[stories objectAtIndex: storyIndex] objectForKey:@"link"]); [self.navigationController pushViewController:extendedView animated:YES]; [extendedView release]; } However, since I can print the value using NSLog in the extendedView view controller I know it's being passed properly. Cheers

    Read the article

  • How to download a wav file from the web to a location on iPhone using NSFileHandle and NSURLConnecti

    - by Jinru
    Hi all, I want to download a wav file from a web service, cache it on the iphone and playback it using AVAudioPlayer. Using NSFileHandle and NSURLConnection seems a viable solution when dealing with relatively large files. However, after running the app in the simulator I don't see any saved file under the defined directory (NSHomeDirectory/tmp). Below is my basic code. Where am I doing wrong? Any thoughts are appreciated! #define TEMP_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"tmp"] - (void)downloadToFile:(NSString*)name { NSString* filePath = [[NSString stringWithFormat:@"%@/%@.wav", TEMP_FOLDER, name] retain]; self.localFilePath = filePath; // set up FileHandle self.audioFile = [[NSFileHandle fileHandleForWritingAtPath:localFilePath] retain]; [filePath release]; // Open the connection NSURLRequest* request = [NSURLRequest requestWithURL:self.webURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; } #pragma mark - #pragma mark NSURLConnection methods - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data { [self.audioFile writeData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError*)error { NSLog(@"Connection failed to downloading sound: %@", [error description]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; [audioFile closeFile]; }

    Read the article

  • NSMutableURLRequest wont try to use 3G when 3G is not 'connected' in Reachability enumeration

    - by Kyle
    I won't bother posting any code because my code works fine when I launch Safari or something that turns on the 3G connection first. When I put it Airport mode, then put back OFF, I will get the behavior of a connection error saying No internet connection with NSMutableURLRequest. I've personally mailed apple about how the Ant gets turned on and off, and they said anything that uses their base CFSocketStream object will turn on the Ant, and I quote: "such as NSURLRequest".. BSD Sockets do not, just so everyone knows.. However, I assumed NSMutableURLRequest would fall into the category of 'Does', but it seems like it doesnt. It never succeeds for me when I cycle Airport or have the phone idle for a long time. It will ALWAYS succeed when I open any other network app first to turn the Ant on. Shall I be forced to do a dummy NSURLRequest call to turn this on; or has anyone been able to get this class working just fine? Remember this is just an implementation of NSMutableURLRequest to upload a file Async, and no other Network operations are performed anywhere; no ads, no version checks, no nothing.

    Read the article

  • iPhone SDK - (void)viewDidLoad { } - Show Progress

    - by Hank Brekke
    I have a long - (void)viewDidLoad { } function that uses the internet to load a page, and whenever the application loads the URL, the screen is black. I have a UIActivityIndicator setup to show that the address is loading, but I don't know how to prevent it from seeming as if the application is not responding, and I don't want to show the network activity indicator [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; because the screen will still be black, just with a loader in the top corner. My code is below: - (void)viewDidLoad { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; email.text = [defaults objectForKey:@"mom_email"]; pass.text = [defaults objectForKey:@"mom_pass"]; if (email.text != nil && pass.text != nil) { [self login:loginBtn]; } } - (IBAction)login:(id)sender { [email resignFirstResponder]; [pass resignFirstResponder]; [loader startAnimating]; // Does nothing though NSString *em = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)email.text,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8); NSString *ps = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)pass.text,NULL,(CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8); NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:@"localhost" path:[[NSString alloc] initWithFormat:@"/app/login.php?email=%@&pass=%@", em, ps]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *loginResult = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; [loader stopAnimating]; NSRange range = [loginResult rangeOfString:@"1"]; if (range.location != NSNotFound) { [self dismissModalViewControllerAnimated:YES]; // Doesn't do anything if function called from viewDidLoad } }

    Read the article

  • UIWebView not loading URL

    - by jerincbus
    I'm having trouble getting a UIWebView to load a URL that I'm sending to it. Before I get into my code I was wondering if URL has to start with "http://" or can it start with "www."? I'm using an IBAction to push a UIView on to the stack: (IBAction)goToWebView { WebViewController *webController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]]; //set the strings webController.webTitle = [self Title]; webController.webURL = [self website]; //Push the new view on the stack [[self navigationController] pushViewController:webController animated:YES]; [webController release]; webController = nil; } Then here is my WebViewController.h file: @interface WebViewController : UIViewController { IBOutlet UIWebView *webView; NSString *webTitle; NSString *webURL; } @property (nonatomic, retain) IBOutlet UIWebView *webView; @property (nonatomic, retain) NSString *webTitle; @property (nonatomic, retain) NSString *webURL; here And my WebViewController.m file: - (void)viewDidLoad { [super viewDidLoad]; NSString *urlAddress = webURL; //Create a URL object. NSURL *url = [NSURL URLWithString:urlAddress]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [webView loadRequest:requestObj]; }

    Read the article

  • NSURL Connection will/won't load data

    - by jkap
    So here's my issue: I followed the NSURLConnection tutorial in the iPhone Developer Documentation almost to the T, and it only kinda works. Here's where it all goes wrong: The object seems to be created correctly and delegates to connectionDidFinishLoading, but with any URL I try to load the response data always ends up only being 0 bytes. I am running in the simulator if that makes any difference. Here's my relevant code: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"WVFS Player"; //create a request NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://wvfs.josh-kaplan.com/nowPlaying.php"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create a connection NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if(theConnection) { // create the datum responseData=[[NSMutableData data] retain]; } else { // code this later } } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // make it work NSLog(@"Succeeded! Received %d bytes of data:",[responseData length]); // release it [connection release]; [responseData release]; } And here's my log output: [Session started at 2010-03-14 09:01:09 -0400.] 2010-03-14 09:01:14.784 WVFS[19571:207] Succeeded! Received 0 bytes of data: Any ideas? Thanks, Josh

    Read the article

  • How to call JSON asynchronous in xcode/ iphone develope

    - by Frames84
    I'm using the JSON framework hosting on Google. What and it's a news app that loads JSON feeds, when app goes off to load the feed I want to display the UIActivityIndicatorView but I've found my JSON Access code is not being called asynchronous which is locking the user interface. I have highlighted the function in the code and can't figuree out without breaking how to change the code. #import "JSON DataAccess Wrapper.h" #import "JSON.h" @implementation JSON_DataAccess_Wrapper @synthesize dataItemList; ////////////////////////////////////////////// /* START FEED CONNECTION/ HANDLE METHODS */ ////////////////////////////////////////////// - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { //label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } - (NSString *)stringWithUrl:(NSURL *)url { NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30]; NSData *urlData; NSURLResponse *response = nil; NSError *error = nil; /* HOW TO MAKE THE CALL BELOW ASYNCHRONOUS */ urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; return [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]; } -(id) objectWithUrl:(NSURL *)url { SBJSON *jsonParser = [SBJSON new]; NSString *jsonString = [self stringWithUrl:url]; return [jsonParser objectWithString:jsonString error:NULL]; } - (NSMutableArray *) downloadJSONFeed { id response = [self objectWithUrl:[NSURL URLWithString:@"http://www.mysite.co.uk/index2.php?option=JSON"]]; NSMutableArray *feed = (NSMutableArray *) response; return feed; }

    Read the article

  • Asynchronous NSURLConnection Throws EXC_BAD_ACCESS

    - by Sheehan Alam
    I'm not really sure why my code is throwing a EXC_BAD_ACCESS, I have followed the guidelines in Apple's documentation: -(void)getMessages:(NSString*)stream{ NSString* myURL = [NSString stringWithFormat:@"http://www.someurl.com"]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { receivedData = [[NSMutableData data] retain]; } else { NSLog(@"Connection Failed!"); } } And my delegate methods #pragma mark NSURLConnection Delegate Methods - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { // This method is called when the server has determined that it // has enough information to create the NSURLResponse. // It can be called multiple times, for example in the case of a // redirect, so each time we reset the data. // receivedData is an instance variable declared elsewhere. [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Append the new data to receivedData. // receivedData is an instance variable declared elsewhere. [receivedData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // release the connection, and the data object [connection release]; // receivedData is declared as a method instance elsewhere [receivedData release]; // inform the user NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // do something with the data // receivedData is declared as a method instance elsewhere NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); // release the connection, and the data object [connection release]; [receivedData release]; } I get an EXC_BAD_ACCESS on didReceiveData. Even if that method simply contains an NSLog, I get the error. Note: receivedData is an NSMutableData* in my header file

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >