gpt4 book ai didi

ios - 传递字符串时崩溃

转载 作者:行者123 更新时间:2023-11-28 18:52:02 26 4
gpt4 key购买 nike

传递字符串参数时我的代码崩溃了。

有人可以帮我解决这个问题吗? :

- (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:]: unrecognized selector sent to instance 0x7fc89b0028d0

2016-10-14 14:54:24.118 Myapp[7824:109039] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController itemstring:]: unrecognized selector sent to instance 0x7fc89b0028d0'

我的VC

#import <UIKit/UIKit.h>

@interface MyVC : UIViewController {
NSString* itemstring;
}

@property (nonatomic, strong) NSString* itemstring;

@end

最佳答案

错误中的行...

-[UIViewController itemstring:]: unrecognized selector sent to instance 0x7fc89b0028d0

这表明 segue 的目标是 UIViewController 而不是 MyVC

您可能没有在 Storyboard中正确设置子类。

你可以在这里更新它...

enter image description here

通过将 Class 更改为 MyVC

关于ios - 传递字符串时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40039760/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com