选定的答案对我有用,但它给了我一个语义警告。即使代码有效,我也对警告有点保留,所以我想知道是否有办法让它在没有警告的情况下工作。
警告是:
找不到实例方法“-SetPrompt:”(返回类型默认为“id”)
这是我在遵循这个问题的答案时所做的。
在调用 .m 文件中
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
vcSelection *ViewSelection = [[vcSelection alloc] initWithNibName:@"vcSelection" bundle:nil];
ViewSelection.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceType])
{
[ViewSelection SetPrompt:@"Select the device type."];
}
else if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceManufacturer])
{
[ViewSelection SetPrompt:@"Select the device manufacturer."];
}
else if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceModel])
{
[ViewSelection SetPrompt:@"Select the device model."];
}
[self.view addSubview:ViewSelection.view];
}
在接收 .m 文件中
@implementation vcSelection
NSMutableString *Prompt;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Debug"
message:Prompt
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alert show];
[alert release];
}
- (void) SetPrompt:(NSMutableString *)Value
{
Prompt = Value;
}
@end