【发布时间】:2016-10-14 09:32:34
【问题描述】:
我的代码在传递字符串参数时崩溃。
有人可以帮我排序吗? :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSIndexPath *indexPath = (NSIndexPath *)sender;
if ([[segue identifier] isEqualToString:@"abc"]) {
MyVC *myvc = [segue destinationViewController];
myvc.itemstring=@"dsdsds";
}
}
错误
-[UIViewController itemstring:]:无法识别的选择器发送到实例 0x7fc89b0028d0
2016-10-14 14:54:24.118 Myapp[7824:109039] *** 由于应用程序终止 未捕获的异常“NSInvalidArgumentException”,原因: '-[UIViewController itemstring:]: 无法识别的选择器发送到 实例 0x7fc89b0028d0'
我的VC
#import <UIKit/UIKit.h>
@interface MyVC : UIViewController {
NSString* itemstring;
}
@property (nonatomic, strong) NSString* itemstring;
@end
【问题讨论】:
-
用 MyVC 控制器更新你的问题
-
显示错误。
-
NSIndexPath *indexPath = (NSIndexPath *)sender 有什么用?在这里
-
崩溃日志中有什么内容?哪条线路崩溃了?
-
[segue destinationViewController]似乎是UIViewController对象而不是MyVC对象。在 InterfaceBuilder 中,您没有将类设置为UIViewController到MyVC。
标签: ios objective-c iphone