我几乎完成了通过本教程的工作方式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!多数民众赞成在它看到它,想要拍自己。 –
感谢您的帖子。 –