Questions about the structure of iPhone applications - basic data, views, modal views, etc.

About a month ago, my wife and I came up with a good idea for an iPhone application, so I started thinking about how the application would work from the point of view of users, and about a week ago I first opened Xcode and started to develop.

Before I get too stuck in writing an application, I want to make sure that I have some key concepts that I understand, especially those related to architecture.

FYI, as a principle, I would like to try to create as many software applications as possible (in particular, the user interface) so that I have a full understanding of what is happening. Later, I could use IB as a tool to speed up the development of the user interface (currently applied because I use TableViews instead of static views).

View controllers

  • Thus, UINavigationControllers, as a rule, are not subclasses and are created as a property in AppDelegate and are the main "subview" of MainWindow.xib.

  • The UINavigationController manages the view stack and usually starts with the root view controller.

  • The navigation controller is usually referenced and dispatched from the current / top view controller as [self navigationcontroller], which is read-only for the parent class of the UIViewController.

Basic data

  • The context of managed objects is the main control point for accessing data in the model, but it is usually not used directly, and instead, selection queries are used to return arrays, sets, or dictionaries of data objects, which are then used to view controllers for data presentation and management.

  • the context is created as a property in the application deletion and then passed to the root view controller at startup, which itself passes it to subsequent views on the stack before telling the navigation controller to change the view (for example, when the cell is used).

, , , , Modal Views, , , ( - )?

, "" , ?

, .

+5
2

, presentModalViewController: . , , .

DetailViewController dvc = ...;
dvc.model = model;
dvc.delegate = self; // if you want to use a delegate pattern.
[self presentModalViewController:dvc animated:YES];

, , , viewDidLoad. iOS , , .

- (void)viewDidLoad {
    [super viewDidLoad];
    self.someTextField.text = self.model.someText;
}

, , . . "" "". :

[self dismissModalViewControllerAnimated:YES];

, , . , , , . , . , "", , .

- (IBAction)save:(id)sender {
    self.model.someText = self.someTextField.text;
    [self.delegate detailViewControllerDidSave:self];
}

:

-(void)detailViewControllerDidSave:(DetailViewController *)controller {
  // save the model
  [self dismissModalViewControllerAnimated:YES];
}
+2

, /. CoreData, .

  • - . , , , .

  • , . " " , ( MVC).

0

All Articles