Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7735475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:30:40+00:00 2026-06-01T07:30:40+00:00

like to save users personal info (name, phone number etc) to a file using:

  • 0

like to save users personal info (name, phone number etc) to a file using: NSKeyedArchiver for later use.

Getting following error when I click on SaveButton:

2012-03-30 14:01:11.483 Archive2[41840:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[__NSArrayM insertObject:atIndex:]: object cannot be nil’
* First throw call stack:
(0x13c8022 0x1559cd6 0x13b533e 0x13b61f0 0x2917 0x13c9e99 0x1514e 0x150e6 0xbbade 0xbbfa7 0xbb266 0x3a3c0 0x3a5e6 0x20dc4 0x14634 0x12b2ef5 0x139c195 0x1300ff2 0x12ff8da 0x12fed84 0x12fec9b 0x12b17d8 0x12b188a 0x12626 0x1f9d 0x1f05)
terminate called throwing an exception(lldb)

h file:

@property (nonatomic, strong) IBOutlet UITextField *vorname;
@property (nonatomic, strong) IBOutlet UITextField *nachname;
@property (nonatomic, strong) IBOutlet UITextField *ausweisNR;
@property (nonatomic, strong) IBOutlet UITextField *serviceNR;
@property (nonatomic, strong) IBOutlet UITextField *telephoneNumber;
@property (nonatomic, strong) NSString *dataFilePath;

-(IBAction)saveData:(id)sender;

m file:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSFileManager *filemgr;
    NSString *docsDir;
    NSArray *dirPaths;

    filemgr = [NSFileManager defaultManager];

    //Get the documents directory:
    dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = [dirPaths objectAtIndex:0];

    // Build the path to the data file:
    dataFilePath = [[NSString alloc]initWithString:[docsDir stringByAppendingPathComponent:@"data.archive"]];

    // Check if the file already exist:
    if ([filemgr fileExistsAtPath:dataFilePath]) // File exist so rebuild...
    {
        NSMutableArray *userCredentials;
        userCredentials = [NSKeyedUnarchiver unarchiveObjectWithFile:dataFilePath];

        self.serviceNR.text = [userCredentials objectAtIndex:0];
        self.ausweisNR.text = [userCredentials objectAtIndex:1];
        self.vorname.text = [userCredentials objectAtIndex:2];
        self.nachname.text = [userCredentials objectAtIndex:3];
        self.telephoneNumber.text = [userCredentials objectAtIndex:4];
    }
}



-(IBAction)saveData:(id)sender
{
    NSMutableArray *userCredentials = [[NSMutableArray alloc]init];

    [userCredentials addObject:self.serviceNR.text];
    [userCredentials addObject:self.ausweisNR.text];
    [userCredentials addObject:self.vorname.text];
    [userCredentials addObject:self.nachname.text];
    [userCredentials addObject:self.telephoneNumber.text];
    [NSKeyedArchiver archiveRootObject:userCredentials toFile:dataFilePath];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:30:41+00:00Added an answer on June 1, 2026 at 7:30 am

    One of your text fields is empty.
    You should test them first.

    if([self.serviceNR.text length]){
        [userCredentials addObject:self.serviceNR.text];
    }
    

    and so on….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to save data in cookies (user name, email address, etc...) but
My system enables users to save their work as a draft. I'd like to
I'd like to build a web application which allow iPhone users to save a
I'd like to save some simple text data to a file from my Silverlight
i save a user like this in doctrine: $user = User(); $user->name = 'peter';
I would like to implement a save feature, which allows my users to save
I would like to implement an apps that allow users save the webpage including
I'd like to store emails in a separate table and allow users to save
I'm trying to save some users in a custom admin form and I'd like
I would like to save the programs settings every time the user exits the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.