我剛被卡住了。我有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