我花了幾個小時試圖解決這個問題 我試圖初始化類參數Init方法與參數不叫
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Fetch the value of the selected row in NSString
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// NSString *tableRowValue = cell.text;
tableRowValue = [[listOfItems objectAtIndex:indexPath.row]objectForKey: @"clientId"];
//Call the next view
ContactsList *contactsList = [[ContactsList alloc] initWithNibName:NSStringFromClass([ContactsList class]) bundle:nil];
@try {
[self presentModalViewController:contactsList animated:YES];
}
@catch (NSException *ex) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",ex]
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
contactsList.modalTransitionStyle = UIModalTransitionStyleCrossDissolve ;
//Initialize the view with the clicked row value thwough NSString variable
[contactsList init:tableRowValue];
}
這行代碼
[contactsList init:tableRowValue];
我得到以下警告:未使用表達式結果
和ContactsList類中的init方法未被調用
感謝您的幫助
如果你想壓制警告,你可以用(void)加入。我會改變你的方法名稱。 init用於實例化對象。如果你想添加一個變量,然後使用'intiWithTableRowValue:tableRowValue' – Fogmeister
謝謝你,我編輯了我的代碼。在init方法 – janeloulou
之前調用ViewDidLoad方法,因爲您在intiWithTableRowValue之前調用presentModalViewController。 – Rajneesh071