コードでやりたいことは、あるビューから別のビューに移動することだけです。さまざまな方法で回避しようとしても、現在のビューからのセグエまたは変更により、次のエラーが発生します。
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
どのオブジェクトについて話しているのかまったくわからず、アプリが私のセグエ行でクラッシュしています。ああ、私はXcode 5-DPとiOS 7を使用しています。これが私のソースです:
LoginViewController.h
#import <UIKit/UIKit.h>
#import "ECSlidingViewController.h"
#import "MenuViewController.h"
#import <MessageUI/MessageUI.h>
#import <CoreData/CoreData.h>
@interface LoginViewController : UIViewController <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *userTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
- (IBAction)signupTouched:(UIButton *)sender;
- (IBAction)logInPressed:(id)sender;
- (IBAction)backgroundTouched:(id)sender;
- (IBAction)revealMenu:(id)sender;
@end
LoginViewController.m (8 行目の例外)
#import "LoginViewController.h"
#import "RegisterView.h"
#import <Parse/Parse.h>
@implementation LoginViewController
- (IBAction)signupTouched:(UIButton *)sender {
[self performSegueWithIdentifier:@"signup" sender:self];
// THE APPLICATION CRASHES ON THIS LINE ABOVE
}
//Login button pressed
-(IBAction)logInPressed:(id)sender
{
//If user logged succesful:
//[self performSegueWithIdentifier:@"LoginSuccesful" sender:self];
if (![self.userTextField.text isEqual:@""]) {
[PFUser logInWithUsernameInBackground:self.userTextField.text password:self.passwordTextField.text block:^(PFUser *user, NSError *error) {
if (user) {
//Open the wall
//[self performSegueWithIdentifier:@"LoginSuccesful" sender:self];
UIAlertView *loginAlertView = [[UIAlertView alloc] initWithTitle:@"Great!" message:@"You have logged in" delegate:nil cancelButtonTitle:@"Get roaming" otherButtonTitles:nil, nil];
[loginAlertView show];
} else {
//Something bad has ocurred
NSString *errorString = [[error userInfo] objectForKey:@"error"];
UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[errorAlertView show];
}
}];
} else {
//Something bad has ocurred
NSString *errorString = @"You did not type any credentials!";
UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[errorAlertView show];
}
}
- (IBAction)backgroundTouched:(id)sender {
[self.userTextField resignFirstResponder];
[self.passwordTextField resignFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
}
self.slidingViewController.underRightViewController = nil;
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
- (IBAction)revealMenu:(id)sender
{
[self.slidingViewController anchorTopViewTo:ECRight];
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.userTextField.delegate = self;
self.passwordTextField.delegate = self;
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
[self setUserTextField:nil];
[self setPasswordTextField:nil];
[super viewDidUnload];
}
@end
私はググった、そして私はググった。このような問題を抱えている人は他にいないようです。他の人にとってはうまくいくように見える解決策に従って、iOSシミュレーター全体とすべてを無駄に掃除しようとしました。可能なすべてのタイプのセグエを試しましたが、どれも機能していません。
前もって感謝します!