Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:03:05+00:00 2026-05-27T16:03:05+00:00

I’m calling a webservice in viewDidLoad method of tableViewcontroller class and parsing the data

  • 0

I’m calling a webservice in viewDidLoad method of tableViewcontroller class and parsing the data in another class as follows

- (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);
}

and then setting this severity array value in table cell as

- (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;
}

The table remains empty but NSLog displays all the data correctly.

Also, after the web service is called and parsed, my app crashes in simulator without any error msg in debugger.

How do I display these values in array to tableview?

Guess what.. the nslog message for cellValue or any other nslog msg i include in tabelView:cellForRowAtIndexPath does not gets printed in console..

Here is the my console view

[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
)

Iam sharing few source code files here: https://gist.github.com/fce50a3c4d20cb9c4677
Kindly have a look if you can find any bugs. My app seems like it was made to crash only:(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:03:05+00:00Added an answer on May 27, 2026 at 4:03 pm

    Check whether [severity objectAtIndex:indexPath.row] returns you NSString , I think it should be some thing else

     NSString* cellValue = [severity objectAtIndex:indexPath.row];
    

    And as well as try [tableView reloadData] as mentioned by the.evangelist

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want to construct a data frame in an Rcpp function, but when I
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.