Ios 如何用sudzc填充表格视图?(我的财产不起作用)

Ios 如何用sudzc填充表格视图?(我的财产不起作用),ios,ipad,tableview,sudzc,Ios,Ipad,Tableview,Sudzc,我有一个使用sudzc的类。所有这些都可以正常工作,使用NSLog,我可以查看web服务的数据,但是当我想使用一个数组,然后在其他地方使用该数组时,该属性为null。我想用web服务的数据填充表视图,但我做不到,怎么能做到呢 这是我的课 // // RootViewController.m // StratargetMovil // // Created by Giovanni Cortés on 30/03/12. // Copyright (c) 2012 __MyCo

我有一个使用sudzc的类。所有这些都可以正常工作,使用NSLog,我可以查看web服务的数据,但是当我想使用一个数组,然后在其他地方使用该数组时,该属性为null。我想用web服务的数据填充表视图,但我做不到,怎么能做到呢

这是我的课

       //
//  RootViewController.m
//  StratargetMovil
//
//  Created by Giovanni Cortés on 30/03/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "RootViewController.h"
#import "Page2.h"

@interface RootViewController ()
@end

@implementation RootViewController
@synthesize myData = _myData;
@synthesize empresaID = _empresaID;
@synthesize datos = _datos;
@synthesize idUnidadNegocio = _idUnidadNegocio;
@synthesize idArray = _idArray;

-(NSString *)empresaID
{
    _empresaID = @"fce";
    return _empresaID;
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        // Do any additional setup after loading the view from its nib.

    }
    return self;
}

- (void)viewDidLoad
{    
    // I want to fill the table view but dont work
    EWSEmpresaWebServiceSvc *service = [[EWSEmpresaWebServiceSvc alloc] init];
    [service ConsultarUnidadesOrganizacionalesPorEmpresa:self EmpresaId:self.empresaID];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.datos = nil;
    self.myData = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}



// Lo de la tabla
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.myData count];
}

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

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];

    }

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [self.myData objectAtIndex:row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;

}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Muestra la vista 2 cuando se selecciona una fila
    [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];

    self.idUnidadNegocio = [self.idArray objectAtIndex:indexPath.row];

    Page2 *nextNavigator = [[Page2 alloc] init];

    [[self navigationController] pushViewController:nextNavigator animated:YES];
    [nextNavigator release];


}

// -------------------------------------------------
// Consultar unidades organizaciones por empresa
- (void) ConsultarUnidadesOrganizacionalesPorEmpresaHandler: (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 *result = (NSMutableArray*)value;
    NSMutableArray *unidadOrganizacional = [[NSMutableArray alloc] init];
    self.myData = [[[NSMutableArray array] init] autorelease];

    for (int i = 0; i < [result count]; i++)
    {
        EWSUnidadNegocio *empresa = [[EWSUnidadNegocio alloc] init];
        empresa = [result objectAtIndex:i];
        [unidadOrganizacional addObject:[empresa Descripcion]];

    }

    self.myData = unidadOrganizacional;

}
 -(void)onload:(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 *result = (NSMutableArray*)value;
    NSMutableArray *unidadOrganizacional = [[NSMutableArray alloc] init];
    self.myData = [[[NSMutableArray array] init] autorelease];

    for (int i = 0; i < [result count]; i++)
    {
        EWSUnidadNegocio *empresa = [[EWSUnidadNegocio alloc] init];
        empresa = [result objectAtIndex:i];
        NSLog(@"%ld -- %@", [empresa Id], [empresa Descripcion]); // With this I can watch the data in the console
        [unidadOrganizacional addObject:[empresa Descripcion]];

    }

    self.myData = unidadOrganizacional; // self.myData in another place is null
}


}
@end
//
//RootViewController.m
//StratargetMovil
//
//由Giovanni Cortés于2012年3月30日创作。
//版权所有(c)2012年\uuuu MyCompanyName\uuuuu。版权所有。
//
#导入“RootViewController.h”
#导入“Page2.h”
@接口RootViewController()
@结束
@RootViewController的实现
@综合myData=\u myData;
@合成empresaID=\u empresaID;
@合成datos=_datos;
@合成IdunidAndNegocio=_IdunidAndNegocio;
@综合艾达瑞=_艾达瑞;
-(NSString*)empresaID
{
_empresaID=@“fce”;
返回(empresaID);;
}
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
//从nib加载视图后,执行任何其他设置。
}
回归自我;
}
-(无效)viewDidLoad
{    
//我想填充表视图,但不工作
EWSEmpresaWebServiceSvc*服务=[[EWSEmpresaWebServiceSvc alloc]init];
[服务领事机构ESPOREMPRESA:self EmpresaId:self.EmpresaId];
}
-(无效)视图卸载
{
[超级视频下载];
//释放主视图的所有保留子视图。
//例如,self.myOutlet=nil;
self.datos=零;
self.myData=nil;
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
返回YES;
}
//塔布拉酒店
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
返回[self.myData count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*SimpleTableIdentifier=@“SimpleTableIdentifier”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
如果(单元格==nil)
{
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:SimpleTableIdentifier]自动释放];
}
NSUTEGER行=[indexPath行];
cell.textlab.text=[self.myData objectAtIndex:row];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
返回单元;
}
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath
{
//第二世界博物馆
[[tableView cellForRowAtIndexPath:indexPath]setSelected:否:是];
self.idUnidadNegocio=[self.idArray objectAtIndex:indexPath.row];
Page2*nextNavigator=[[Page2 alloc]init];
[[self-navigationController]pushViewController:nextNavigator动画:是];
[nextNavigator发布];
}
// -------------------------------------------------
//联合组织领事馆
-(void)ConsultarUnidadeOrganizationalESPOREMPRESAHandler:(id)值{
//处理错误
if([value iskindof类:[n错误类]]){
NSLog(@“%@”,值);
返回;
}
//处理故障
if([value iskindof类:[SoapFault类]]){
NSLog(@“%@”,值);
返回;
}               
//对NSMutableArray*结果执行一些操作
NSMutableArray*结果=(NSMutableArray*)值;
NSMutableArray*UnidaOrganizational=[[NSMutableArray alloc]init];
self.myData=[[NSMutableArray]init]autorelease];
对于(int i=0;i<[结果计数];i++)
{
EWSUnidadNegocio*empresa=[[EWSUnidadNegocio alloc]init];
empresa=[结果对象索引:i];
[UnidaOrganizational addObject:[empresa Description]];
}
self.myData=unidadOrganizacional;
}
-(void)onload:(id)值
{
//处理错误
if([value iskindof类:[n错误类]]){
NSLog(@“%@”,值);
返回;
}
//处理故障
if([value iskindof类:[SoapFault类]]){
NSLog(@“%@”,值);
返回;
}               
//对NSMutableArray*结果执行一些操作
NSMutableArray*结果=(NSMutableArray*)值;
NSMutableArray*UnidaOrganizational=[[NSMutableArray alloc]init];
self.myData=[[NSMutableArray]init]autorelease];
对于(int i=0;i<[结果计数];i++)
{
EWSUnidadNegocio*empresa=[[EWSUnidadNegocio alloc]init];
empresa=[结果对象索引:i];
NSLog(@%ld--%@,[empresa Id],[empresa description]);//有了它,我可以在控制台中查看数据
[UnidaOrganizational addObject:[empresa Description]];
}
self.myData=unidadoorganizacional;//另一个位置的self.myData为null
}
}
@结束
我的数据是

@属性(非原子,保留)NSMutableArray*myData


谢谢

我想
我的数据
自动删除了。 您可以分配并初始化
myData
数组,但不能自动释放它。(在中的
myData
分配处删除自动释放。)
ConsultarUnidadeOrganizationalESPOREMPRESAHandler
方法)


不要忘记添加一个dealloc方法来释放
myData
(和其他)属性。

首先,这对您没有任何帮助:

self.myData = [[[NSMutableArray array] init] autorelease];

...

self.myData = unidadOrganizacional;
您正在分配myData,然后立即重新分配它

跳过第一次初始化,只需执行以下操作:

self.myData = [unidadOrganizacional mutableCopy];
我怀疑您在某个点上丢失了指向UnidaOrganizational数组的指针,这就是为什么myData会变为null的原因

就我个人而言,我只是在viewDidLoad调用中初始化myData,然后直接将对象添加到myData中:

- (void)viewDidLoad
{    

    self.myData = [[NSMutableArray alloc] init];

    // I want to fill the table view but dont work
    EWSEmpresaWebServiceSvc *service = [[EWSEmpresaWebServiceSvc alloc] init];
    [service ConsultarUnidadesOrganizacionalesPorEmpresa:self EmpresaId:self.empresaID];
}
然后:

- (void) ConsultarUnidadesOrganizacionalesPorEmpresaHandler: (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 *result = (NSMutableArray*)value;

    for (int i = 0; i < [result count]; i++)
    {
        EWSUnidadNegocio *empresa = [[EWSUnidadNegocio alloc] init];
        empresa = [result objectAtIndex:i];
        [self.myData addObject:[empresa Descripcion]];
    }
}

-(void)onload:(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 *result = (NSMutableArray*)value;

    for (int i = 0; i < [result count]; i++)
    {
        EWSUnidadNegocio *empresa = [[EWSUnidadNegocio alloc] init];
        empresa = [result objectAtIndex:i];
        NSLog(@"%ld -- %@", [empresa Id], [empresa Descripcion]); // With this I can watch the data in the console
        [self.myData addObject:[empresa Descripcion]];

    }
}
-(void)ConsultarUnidadeOrganizationalESPOREMPRESAHandler:(id)值{
//处理错误
if([value iskindof类:[n错误类]]){
N