我刚被卡住了。我有2个视图控制器,一个是“WatchListViewController
”,第二个是“QuotesViewController
”首先我从WatchListViewController
推到QuotesViewController
,我的动作写在这里。保留一个NSMutableArray的值?
-(IBAction)qoutes
{
QuotesViewController *nextController = [[QuotesViewController alloc] initWithQoutes:symbolForQoutes :exchangeForQoutes :appDelegate.s :code :exchange:exchangeCodeForQoutes];
[self.navigationController pushViewController:nextController animated:YES];
}
它完美的作品我initWithQoutes
方法也工作好,那么在ViewDidLoad
方法,我通过套接字发送一些请求到服务器,它提供了响应和效应初探在我的功能就是在WatchListViewController
收到:
void receiveData(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
char *buffer = (char *)CFDataGetBytePtr((CFDataRef)data); //getting data from server side in a char type veriable "buffer"
NSString *result = [NSString stringWithUTF8String:buffer]; // getting data in a string from my buffer
if (strstr(buffer, "QRES") != NULL) { //if this is a qoutes response
splits = [result componentsSeparatedByString:@"|"]; //separating string by "|"
body = [splits objectAtIndex:1]; // choosing index "1"
splits = [body componentsSeparatedByString:@","]; // separating by ","
QuotesViewController *quotesViewController = [[QuotesViewController alloc] init];
[quotesViewController initWithData:splits];
return;
}
}
响应被接收,并且它转到方法initWithData
带有参数数组“分裂的” i收到此阵列中的我的initWithData并将其分配给我的其他阵列(generalArray
)现在一般阵列分配给我tableView
但在它之前reloadData
的tableView其控制返回receiveData
并返回并再次返回到我的QuotesViewController
并重新加载表视图,但当时我的数组(generalArray
)失去其值&值不会在表视图中加载值。 plz plz帮我我卡在这里。方法initWithData的
代码:
-(void)initWithData:(NSArray *)_general
{
general = [[NSMutableArray alloc] init]; //initializing array that can be accessed out of the class
for (int i=0; i< [_general count]; i++) {
[general addObject:[_general objectAtIndex:i]]; }
NSLog(@"%@", general); [self generalValues];
}
-(void)generalValues{
[generalTableView reloadData];
}
当我读到最后一个声明时,我可能会清楚该链接是否丢失。 – Radix 2011-05-18 13:00:07