我幾乎完成了通過本教程的工作方式here 它的內容非常豐富,幫助我理解了協議和委託如何協同工作來傳遞數據。使用協議和代理在視圖之間傳遞數據
但是我有一個警告,當我試圖告訴我的子視圖,主視圖是它的委託時彈出。其發回此警告
「+ setDelegate:」未找到(返回類型默認爲‘身份證’)」
一切都步入正軌了,直到這一點上,我只是woundering這個錯誤是什麼意味着什麼,如果這與我實施我的代碼的方式有關。
下面就是警告正在發生的事情...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
//--- Idendify selected indexPath (section/row)
if (indexPath.section == 0) {
//--- Get the subview ready for use
VehicleResultViewController *vehicleResultViewController = [[VehicleResultViewController alloc] initWithNibName:@"VehicleResultViewController" bundle:nil];
// ...
//--- Sets the back button for the new view that loads
self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:vehicleResultViewController animated:YES];
[VehicleResultViewController setDelegate:self]; //<<-- warning here says -->> Method'+setDelegate:' not found (return type defaults to 'id')
switch (indexPath.row)
{
case 0: vehicleResultViewController.title = @"Manufacture";
[vehicleResultViewController setRequestString:@"manufacture.php"]; //sets the request string in searchResultsViewController
break;
//...
任何幫助將不勝感激。
更新,這是我怎麼設置我委託了 SecondView.h
//...
@interface VehicleResultViewController : UITableViewController <NSXMLParserDelegate> {
//..
id <PassSearchData> delegate;
}
//..
@property (retain) id delegate;
@end
SecondView.m
//..
@synthesize delegate;
//..
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[[self delegate] setVehicleSearchFields:vehicleCellTextLabel];
}
//..
我希望這更好的闡明我在做什麼。
YUP!多數民衆贊成在它看到它,想要拍自己。 –
感謝您的帖子。 –