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 9142671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:50:08+00:00 2026-06-17T09:50:08+00:00

`-(IBAction)saveData { //get paths from root directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, /* */ NSUserDomainMask,

  • 0
 `-(IBAction)saveData
    {
        //get paths from root directory
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,        /*   */  NSUserDomainMask, YES);

//get documents path
        NSString *documentsPath = [paths objectAtIndex:0];

//get the path to our Data/plist file
    NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Data.plist"];


//set the variables to the values in the text fields
        self.personName = nameEntered.text;
        self.phoneNumbers = [[NSMutableArray alloc] initWithCapacity:3];
        [phoneNumbers addObject:myPhone.text];
        [phoneNumbers addObject:momPhone.text];
        [phoneNumbers addObject:dadPhone.text];

        //create dictionary with values in UITextFields
        NSDictionary *plistDict = [NSDictionary dictionaryWithObjects: 
[NSArray arrayWithObjects: personName, phoneNumbers, nil] forKeys:
[NSArray arrayWithObjects: @"Name", @"Phones", nil]];

        NSString *error = nil;
        //create NSData from dictionary
        NSData *plistData = [NSPropertyListSerialization dataFromPropertyList: plistDict             /* */   format: NSPropertyListXMLFormat_v1_0 errorDescription: &error];

    //check if plist data exists
    if (plistData)
    {
        //write plistData to our Data.plist file
        [plistData writeToFile:plistPath atomically: YES];            
    }
    else
    {
        NSLog(@"Error in saveData: %@", error);
        [error release];
    }
}`

I can not find the error with the -(IBAction). It says there is an expected expression. Any help would be greatly appreciated! I am new to coding so I do not know much.

I fixed it guys, thanks for all the help. It was a big rookie mistake I made… I put my actions inside the viewdidload 🙁

  • 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-17T09:50:09+00:00Added an answer on June 17, 2026 at 9:50 am

    For starters the methods names are incorrect
    Wrong:

    [plistData writetoFile:plistPath automatically: YES]; 
    

    Correct:

    [plistData writeToFile:plistPath atomically:YES];
    

    From Apple docs:

    - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

- (IBAction)EnterButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString
-(IBAction)ButtonPressed:(id)sender { const char *sql = SELECT AccessCode FROM UserAccess; NSString *sqlns; sqlns =
-(IBAction)musiconButtonClicked:(id)sender{ NSString *path = [[NSBundle mainBundle] pathForResource:@NextRevIt ofType:@mp3]; AVAudioPlayer* audioPlayer = [[AVAudioPlayer alloc ]
-(IBAction)someMethod:(UIStepper *)sender{ int x=sender.value; //This is an integer from 0-8; NSLog(@%f,sender.value); NSArray *rpmValues =
-(IBAction)gameplayButtonClicked{ GamePlayViewController *screen3 = [[GamePlayViewController alloc] initWithNibName:nil bundle:nil]; screen3.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [self presentModalViewController:screen3 animated:YES];
-(IBAction)EnterButtonPressed:(id)sender { const char *sql = SELECT AccessCode FROM UserAccess; double result = ([Password.text
-(IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@myaudiofile ofType:@caf]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
- (IBAction)SetupButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@MoneyofType:@sqlite];
- (IBAction) someButtonCall { if(!someCondition) { someButtonCallBack = @selector(someButtonCall); [self presentModalViewController:someController animated:YES]; } else

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.