Note that there are some explanatory texts on larger screens.

plurals
  1. POAddress book data persistence?
    primarykey
    data
    text
    <p>(storyboard image) <a href="http://i.stack.imgur.com/DUZ12.png" rel="nofollow">http://i.stack.imgur.com/DUZ12.png</a></p> <p>Have 3 text fields where user inputs data and saves it. Upon opening the application, if there is any save data, the previous input is displayed within the text fields. Problem is, there is only one set of data, while it needs to be an array with multiple people's information. I would like to instead create a navigation controller with cells with names and upon clicking on them it displays the correlating contact info.</p> <p>viewcontroller.h</p> <pre><code> @interface ArchiveViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextField *name; @property (strong, nonatomic) IBOutlet UITextField *address; @property (strong, nonatomic) IBOutlet UITextField *phone; @property (strong, nonatomic) NSString *dataFilePath; - (IBAction)saveData:(id)sender; @end </code></pre> <p>viewcontroller.m</p> <pre><code>@interface ArchiveViewController () @end @implementation ArchiveViewController - (void)viewDidLoad { [super viewDidLoad]; NSFileManager *filemgr; NSString *docsDir; NSArray *dirPaths; filemgr = [NSFileManager defaultManager]; // Get the documents directory dirPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); docsDir = dirPaths[0]; // Build the path to the data file _dataFilePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"data.archive"]]; // Check if the file already exists if ([filemgr fileExistsAtPath: _dataFilePath]) { NSMutableArray *dataArray; dataArray = [NSKeyedUnarchiver unarchiveObjectWithFile: _dataFilePath]; _name.text = dataArray[0]; _address.text = dataArray[1]; _phone.text = dataArray[2]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)saveData:(id)sender { NSMutableArray *contactArray; contactArray = [[NSMutableArray alloc] init]; [contactArray addObject:self.name.text]; [contactArray addObject:self.address.text]; [contactArray addObject:self.phone.text]; [NSKeyedArchiver archiveRootObject: contactArray toFile:_dataFilePath]; } @end </code></pre> <p>Thank you for your time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload