gpt4 book ai didi

ios - 无法执行segue

转载 作者:行者123 更新时间:2023-12-01 18:05:58 26 4
gpt4 key购买 nike

嗨, session block 工作正常,但是当我尝试移动到下一个 Viewcontroller 时,我得到 thread1:Signal SIGABRT ..实际上我正在尝试从服务器获取请求并使用回复来执行以下代码

    - (IBAction)submitb:(id)sender{
if(_otptf.text==self.otpStr && _otptf.text>0){
NSString *post = [NSString stringWithFormat:@"phone=%@",self.stri1];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
//Next up, we read the postData's length, so we can pass it along in the request.
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
// Now that we have what we'd like to post, we can create an NSMutableURLRequest, and include our postData
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://test.kre8tives.com/barebon/customer_checkapi.php"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSLog(@"the data Details is %@", post);
// And finally, we can send our request, and read the reply by creating a new NSURLSession:
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
static NSURLSession* sharedSessionMainQueue = nil;
if(!sharedSessionMainQueue){
sharedSessionMainQueue = [NSURLSession sessionWithConfiguration:nil delegate:nil delegateQueue:[NSOperationQueue mainQueue]];
}

[[sharedSessionMainQueue dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSString *requestReply = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; // this is json string
// NSError *error;
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; // you need to convert to dictionary object
NSLog(@"Req cust:%@",requestReply);
NSLog(@"requestReply cust: %@", jsonDict);
self.tmpv1=[jsonDict valueForKey:@"success"] ;
self.strv1=self.tmpv1;
NSLog(@"tmp storage inside block:%@",self.tmpv1);
if (!error) {
if([self.tmpv1 isEqualToString:@"%@"],"0"){
[self performSegueWithIdentifier:@"x2" sender:self];
//[self performSegueWithIdentifier:@"x2" sender:self];
}
if([self.tmpv1 isEqualToString:@"%@"],"1"){
[self performSegueWithIdentifier:@"b2" sender:self];
}
}
}] resume];
// [self navi];

}
else{
/* what ever */
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Inputs Found or Incorrect Otp!!"
message:@"Please check your input!!."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable id)sender{
if ([[segue identifier] isEqualToString:@"x2"])
{
ProfileViewController *loadCtr = (ProfileViewController *)segue.destinationViewController;
//loadCtr.mobilestrp = self.stri1;
}

else if ([[segue identifier] isEqualToString:@"b2"])
{

}

}

这是我的日志
2017-06-05 12:14:32.884 MenuBar[1496:103465] the data Details is phone=9047038606
2017-06-05 12:14:33.726 MenuBar[1496:103531] requestReply: {
otp = 828712;
success = 1;
}
2017-06-05 12:14:33.727 MenuBar[1496:103531] tmp storage inside block:828712
2017-06-05 12:14:33.728 MenuBar[1496:103531] storage:828712
2017-06-05 12:14:33.729 MenuBar[1496:103531] tmp storage:828712
2017-06-05 12:14:33.738 MenuBar[1496:103465] 9047038606
2017-06-05 12:14:45.069 MenuBar[1496:103465] the data Details is phone=9047038606
2017-06-05 12:14:49.919 MenuBar[1496:103465] Req cust:{"success":0}
2017-06-05 12:14:52.373 MenuBar[1496:103465] requestReply cust: {
success = 0;
}
2017-06-05 12:14:52.715 MenuBar[1496:103465] tmp storage inside block:0
2017-06-05 12:28:08.486 MenuBar[1520:108818] -[WelcomeViewController setCustid:]: unrecognized selector sent to instance 0x7ff98f908790
2017-06-05 12:28:08.491 MenuBar[1520:108818] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [WelcomeViewController setCustid:]: unrecognized selector sent to instance 0x7ff98f908790'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ba31b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010b126141 objc_exception_throw + 48
2 CoreFoundation

提前感谢您的建议!

最佳答案

您没有检查 转义标识符 prepareForSegue方法。

像这样检查它:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable    id)sender{
if([segue.identifier isEqulaToString: @"x2"]){
//x2 view controller settings
}
else if([segue.identifier isEqulaToString: @"b2"]){
//b2 view controller settings
}
}

有了这个,您可以拥有特定的 View Controller 及其要设置的属性。

关于ios - 无法执行segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44363268/

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