Search code examples
objective-cioscocoa-touchsoapsudzc

using SudzC on Dynamic TableView


This is my first time with working on Webservice on Cocoa-touch framework, I am successfully getting data from web-service on console but when i try to pass it on TableView with array , it does not do anything. I think problem is ,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 

That method does not pass on compiler for compile . And even it is going to work , it will get all off data with tags to table text , because using of : cell.textLabel.text = [myDataCell objectAtIndex:indexPath.row];

How can i use them on dynamic cell.text with specified fields ?. Any help will appreciate.

#import "ViewController.h"
#import "REQService.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize sorguTextField,sorguButton,sorguLabelOutput,name;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)getOutput:(id)sender {

    REQService* service = [REQService service];
    service.logging = YES;

    [service NumaradanIsimALL:self action:@selector(NumaradanIsimALLHandler:) msisdn:sorguTextField.text username: @"xxx" password:@"xxxxxxxxx"];



    myDataCell = [[NSMutableArray alloc ] initWithObjects:myData, nil];

}

#pragma notes - View Tables

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    cell = [tableView dequeueReusableCellWithIdentifier:@"myCell"];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"myCell"];
    }
    cell.textLabel.text = [myDataCell objectAtIndex:indexPath.row];
}
@end

Solution

  • It looks like you have not implemented the web-service response handler NumaradanIsimALLHandler method in your view controller class. Implement this method in your code and once you get a response in this method, assign it to myDataCell object and reload the table view (e.g. [tableView reloadData]);

    In this case you are making an Asynchronous web-service call on tap of a button, and as table view delegates would get called as soon as the view would load therefore you would need to reload the table view in NumaradanIsimALLHandler handler method.