Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

object cannot be nil - On a segue?

All I want to do in my code is move from one view to another. No matter how many different ways I try to go around it, any segue or any change from the current view causes this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

There's no indication of what object it's talking about at all, and the app is crashing on my segue line. Oh and I'm using Xcode 5-DP and iOS 7. Here's my source:

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 (Exception on line 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

I've googled, and I've googled. No-one else seems to be having an issue like this. I tried cleaning out my entire iOS Simulator and everything to no avail, following a solution that appeared to work for others. I've tried every type of segue possible and none are working.

Thanks in advance!

like image 633
Gergy008 Avatar asked Apr 18 '26 13:04

Gergy008


1 Answers

Recheck your configuration and use of the ECSlidingViewController, and it's topViewController.

like image 54
Chris Tetreault Avatar answered Apr 20 '26 03:04

Chris Tetreault



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!