Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
iOS Development
Internet file reading problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="sagarshivam" data-source="post: 1262677" data-attributes="member: 203583"><p><strong>Still no solution!!</strong></p><p></p><p>Dear all!</p><p>Still could not make a point to get my work done!</p><p></p><p>I am just explaining part of it where I am feeling difficulty. </p><p>Right now, I just want some file (say .txt file ) to be read from some server and displayed it on debugger console (right now not on UItextview or anywhere else).</p><p></p><p>I was able to manage a decent GUI (as I am really a newbie for all these). Now as I could see that delegate methods are required to serve my purpose.</p><p></p><p>Part of code where I create one button on clicking which "load " function should be called. </p><p>[CODE]</p><p>self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]</p><p> initWithTitle:@"newbutton" </p><p> style:UIBarButtonItemStylePlain </p><p> target:self </p><p> action:@selector(load)] autorelease];</p><p></p><p>[/CODE] </p><p></p><p>and no complain here.</p><p>In the same .m file , I am defining further as :</p><p></p><p>[CODE]</p><p>- (void)load {</p><p> receivedData = [[NSMutableDictionary alloc] init];</p><p> </p><p> NSURL *url1 = [NSURL URLWithString:@"http://172.22.79.169/~spp/test.txt"];</p><p> </p><p> </p><p> [self startAsyncLoad:url1 tag:@"tag1"];</p><p> </p><p> }</p><p></p><p> - (void)startAsyncLoad:(NSURL*)url tag:(NSString*)tag {</p><p> NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];</p><p> CustomURLConnection *connection = [[CustomURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES tag:tag];</p><p> </p><p> if (connection) {</p><p> [receivedData setObject:[[NSMutableData data] retain] forKey:connection.tag];</p><p> }</p><p> }</p><p> - (NSMutableData*)dataForConnection:(CustomURLConnection*)connection {</p><p> NSMutableData *data = [receivedData objectForKey:connection.tag];</p><p> return data;</p><p> }</p><p> </p><p> - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {</p><p> NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];</p><p> [dataForConnection setLength:0];</p><p> }</p><p> </p><p> - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {</p><p> NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];</p><p> [dataForConnection appendData:data];</p><p> }</p><p> </p><p> - (void)connectionDidFinishLoading:(NSURLConnection *)connection {</p><p> NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];</p><p> [connection release];</p><p> </p><p> }</p><p> </p><p>[/CODE]</p><p></p><p></p><p>But this is not working!! Where exactly I am making mistakes.</p><p>I am even unable to build it successfully:</p><p></p><p>errors are:</p><p></p><p>[CODE]</p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62: warning: (Messages without a matching method signature</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:63:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:63: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:64:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:64: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68: error: 'CustomURLConnection' undeclared (first use in this function)</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68: error: 'connection' undeclared (first use in this function)</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:71:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:71: warning: 'NSMutableData' may not respond to '-setObject:forKey:'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:0:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m: At top level:</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:74:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:74: error: expected ')' before 'CustomURLConnection'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75: error: request for member 'tag' in something not a structure or union</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75: warning: 'NSMutableData' may not respond to '-objectForKey:'</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80: error: 'CustomURLConnection' undeclared (first use in this function)</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80: error: expected expression before ')' token</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85: error: 'CustomURLConnection' undeclared (first use in this function)</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85: error: expected expression before ')' token</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: error: 'CustomURLConnection' undeclared (first use in this function)</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: error: expected expression before ')' token</p><p></p><p></p><p>/Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: warning: unused variable 'dataForConnection'</p><p></p><p></p><p></p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="sagarshivam, post: 1262677, member: 203583"] [b]Still no solution!![/b] Dear all! Still could not make a point to get my work done! I am just explaining part of it where I am feeling difficulty. Right now, I just want some file (say .txt file ) to be read from some server and displayed it on debugger console (right now not on UItextview or anywhere else). I was able to manage a decent GUI (as I am really a newbie for all these). Now as I could see that delegate methods are required to serve my purpose. Part of code where I create one button on clicking which "load " function should be called. [CODE] self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"newbutton" style:UIBarButtonItemStylePlain target:self action:@selector(load)] autorelease]; [/CODE] and no complain here. In the same .m file , I am defining further as : [CODE] - (void)load { receivedData = [[NSMutableDictionary alloc] init]; NSURL *url1 = [NSURL URLWithString:@"http://172.22.79.169/~spp/test.txt"]; [self startAsyncLoad:url1 tag:@"tag1"]; } - (void)startAsyncLoad:(NSURL*)url tag:(NSString*)tag { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; CustomURLConnection *connection = [[CustomURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES tag:tag]; if (connection) { [receivedData setObject:[[NSMutableData data] retain] forKey:connection.tag]; } } - (NSMutableData*)dataForConnection:(CustomURLConnection*)connection { NSMutableData *data = [receivedData objectForKey:connection.tag]; return data; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection]; [dataForConnection setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection]; [dataForConnection appendData:data]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection]; [connection release]; } [/CODE] But this is not working!! Where exactly I am making mistakes. I am even unable to build it successfully: errors are: [CODE] /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:62: warning: (Messages without a matching method signature /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:63:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:63: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:64:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:64: warning: 'noXIBViewController' may not respond to '-startAsyncLoad:tag:' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68: error: 'CustomURLConnection' undeclared (first use in this function) /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:68: error: 'connection' undeclared (first use in this function) /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:71:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:71: warning: 'NSMutableData' may not respond to '-setObject:forKey:' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:0:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m: At top level: /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:74:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:74: error: expected ')' before 'CustomURLConnection' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75: error: request for member 'tag' in something not a structure or union /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:75: warning: 'NSMutableData' may not respond to '-objectForKey:' /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80: error: 'CustomURLConnection' undeclared (first use in this function) /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:80: error: expected expression before ')' token /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85: error: 'CustomURLConnection' undeclared (first use in this function) /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:85: error: expected expression before ')' token /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: error: 'CustomURLConnection' undeclared (first use in this function) /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: error: expected expression before ')' token /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90:0 /Users/sagar/Downloads/noXIB/Classes/noXIBViewController.m:90: warning: unused variable 'dataForConnection' [/CODE] [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
macOS & iOS Developer Playground
iOS Development
Internet file reading problem
Top