好的,所以我对 iPhone、Objective C 和 Cocoa Touch 的编程有点陌生,但无法弄清楚这一点。当委托是自我时有很多信息,但我试图将其发送到另一个文件。
这是一些代码...我有以下方法(我通常将其称为函数,但我认为方法是正确的术语)appDelegate.m
[GameUtil showAlertViewWithTag:1 delegate:self withTitle:@"" message:msg cancelButtonTitle:@"New game" otherButtonTitles:@"Main Menu", nil];
我已经正确设置了showAlertViewWithTagGameUtil.h
并且.m
它工作正常。
我遇到的问题是delegate:self
部件......就目前而言,当单击警报视图上的按钮时,它将转到-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
位于我的位置appDelegate.m
(当使用 self 作为委托时,这当然是预期的)。
但是我希望它在单击按钮时将其发送到-(void)alertView:..
另一个名为playField.m
.
我正确设置了alertview playField.m
(已通过在playField.m 中使用delegate:self 调用alertview 进行了测试)。
基本上,我对如何告诉 appDelegate.m 中的 alertview 使用 playField.m 中的委托而不是委托:self 感到困惑。
我想我需要#import playField.m 或 .h at 到 appDelegate.m 但除此之外,我迷失了所有@protocol @interface 的东西。
小步骤会很有帮助,例如“您需要将 XYZ 放在 playField.h 的顶部,将 ABC 放在 playField.m 的顶部”。
我希望这实现起来相当简单,而且我只是缺少一些简单的东西。
提前致谢 :)