`-(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 :(