嗨會話塊工作正常,但是當我想移動到下一個Viewcontroller我得到thread1:信號SIGABRT ..實際上我試圖從服務器獲取請求並使用回覆來執行以下代碼無法執行segue
- (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
在此先感謝您的建議!
'uodateb' outlet連接到某個UI元素,但未在ViewController文件中聲明。有很多關於此的SO帖子,你應該已經檢查過「這個類別不是關鍵值編碼 - 關鍵字」搜索項 –
我沒有像這樣的UI元素,我已經刪除了該元素@ Mr .Bista和是的,我已經經歷了老問題,我抱怨得到任何答案,所以我發佈了一個新的 – Akshay
你有沒有從xib刪除它,用右鍵單擊選項? –