Iphone TableView从Web服务加载行

Iphone TableView从Web服务加载行,iphone,web-services,tableview,Iphone,Web Services,Tableview,我尝试使用xCode将web服务中的行加载到iPhone项目中的tableview对象中 我使用viewDidLoad方法加载项目,在此方法中,我使用以下代码调用我的web服务: eenAccesoCupon* Servicio = [[eenAccesoCupon alloc] init]; Servicio.logging=NO; [Servicio GetCuponesEntrantes:self action:@selector(GetCuponesEntrantesHandler

我尝试使用xCode将web服务中的行加载到iPhone项目中的tableview对象中

我使用viewDidLoad方法加载项目,在此方法中,我使用以下代码调用我的web服务:

eenAccesoCupon* Servicio = [[eenAccesoCupon alloc] init];  

Servicio.logging=NO;
[Servicio GetCuponesEntrantes:self action:@selector(GetCuponesEntrantesHandler:) UsuarioActivo: 4];
我有一个名为listOfItems的NSMutableArray,用于将行加载到TableView。如果我将此数组中的项添加到GetCuponeSentranteHandler中,则tableview不会显示任何行。此处理程序的源代码如下所示:

(void) GetCuponesEntrantesHandler: (id) value {

    // Handle errors
    if([value isKindOfClass:[NSError class]]) {
        NSLog(@"%@", value);
        return;
    }

    // Handle faults
    if([value isKindOfClass:[SoapFault class]]) {
        NSLog(@"%@", value);
        return;
    }               

    // Do something with the NSMutableArray* result
    NSMutableArray* listOfItems = (NSMutableArray*)value;

}
似乎TableView行是在调用web方法之前加载的,因此,TableView方法(如numberOfRowsInSection和cellForRowAtIndexPath)是在调用web服务之前调用的。如果我以这种方式加载viewDidLoad中的行项:

(void)viewDidLoad {
    [super viewDidLoad];

    //Initialize the array.
    listOfItems = [[NSMutableArray alloc] init];

    //Add items
    [listOfItems addObject:@"Iceland"];
    [listOfItems addObject:@"Greenland"];
    [listOfItems addObject:@"Switzerland"];
    [listOfItems addObject:@"Norway"];
    [listOfItems addObject:@"New Zealand"];
    [listOfItems addObject:@"Holland"];
    [listOfItems addObject:@"Ireland"];

    //Set the title
    self.navigationItem.title = @"Countries";

    eenAccesoCupon* Servicio = [[eenAccesoCupon alloc] init];

    Servicio.logging=NO;
    [Servicio GetCuponesEntrantes:self action:@selector(GetCuponesEntrantesHandler:) UsuarioActivo: 4];
    }
在这种情况下,tableview对象仅显示listOfItems中加载的这7个值,从不从GetCuponeSentranteHandler加载任何项


有人知道问题出在哪里吗?

我想GetCuponesEntrantes:方法与网络异步工作。这意味着一旦加载并显示了表视图,它将调用处理程序。 要强制重新加载表视图,只需调用:

[tableView reloadData]
在handler方法的末尾,在赋值之后

NSMutableArray* listOfItems = (NSMutableArray*)value;