Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying parsed values from webservice in tableview
    primarykey
    data
    text
    <p>I'm calling a webservice in <code>viewDidLoad</code> method of tableViewcontroller class and parsing the data in another class as follows</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; dataWebService = [[NSMutableData data] retain]; NSString *authString = [[[NSString stringWithFormat:@"%@:%@",@"admin", @"admin"] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding]; NSMutableURLRequest *request = [[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://172.16.3.47:8980/opennms/rest/alarms?limit=5"]] retain]; [request setValue:[NSString stringWithFormat:@"Basic %@",authString] forHTTPHeaderField:@"Authorization"]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [dataWebService setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [dataWebService appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"Eror during connection: %@", [error description]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString* responseString = [[NSString alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding]; AlarmWSParse* alarmParser = [[AlarmWSParse alloc]init]; severity = [alarmParser xmlParser:responseString]; NSLog(@"no of elements in array %d",[severity count]); NSLog(@"Back to Alarm List View controller and severtiy array is %@",severity); } </code></pre> <p>and then setting this severity array value in table cell as </p> <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [severity count]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell... NSString* cellValue = [severity objectAtIndex:indexPath.row]; NSLog(@"cellvalue %@",cellValue); cell.textLabel.text = cellValue; return cell; } </code></pre> <p>The table remains empty but <code>NSLog</code> displays all the data correctly. </p> <p>Also, after the web service is called and parsed, my app crashes in simulator without any error msg in debugger.</p> <p>How do I display these values in array to tableview?</p> <p>Guess what.. the nslog message for cellValue or any other nslog msg i include in <code>tabelView:cellForRowAtIndexPath</code> does not gets printed in console..</p> <p>Here is the my console view</p> <pre><code>[Session started at 2011-12-22 11:12:07 +0530.] 2011-12-22 11:12:09.358 WebServiceTab[11815:207] do while loopalarm 2011-12-22 11:12:09.359 WebServiceTab[11815:207] severity is MAJOR 2011-12-22 11:12:09.359 WebServiceTab[11815:207] do while loopalarm 2011-12-22 11:12:09.359 WebServiceTab[11815:207] severity is MAJOR 2011-12-22 11:12:09.360 WebServiceTab[11815:207] do while loopalarm 2011-12-22 11:12:09.360 WebServiceTab[11815:207] severity is MAJOR 2011-12-22 11:12:09.360 WebServiceTab[11815:207] do while loopalarm 2011-12-22 11:12:09.360 WebServiceTab[11815:207] severity is MINOR 2011-12-22 11:12:09.361 WebServiceTab[11815:207] do while loopalarm 2011-12-22 11:12:09.361 WebServiceTab[11815:207] severity is MAJOR 2011-12-22 11:12:09.361 WebServiceTab[11815:207] no of elements in array 5 2011-12-22 11:12:09.362 WebServiceTab[11815:207] Back to Alarm List View controller and severtiy array is ( MAJOR, MAJOR, MAJOR, MINOR, MAJOR ) </code></pre> <p>Iam sharing few source code files here: <a href="https://gist.github.com/fce50a3c4d20cb9c4677" rel="nofollow">https://gist.github.com/fce50a3c4d20cb9c4677</a> Kindly have a look if you can find any bugs. My app seems like it was made to crash only:(</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload