text
stringlengths
0
13.4k
XYZToDoItem *item = source.toDoItem;
This is the item that was created when the Done button was tapped.
6.
See whether the item exists.
if (item != nil) {
}
If it’s nil, either the Cancel button closed the screen or the text field had no text, so you don’t want to
save the item.
If it does exist, add the item to your toDoItems array.
2013-10-22 | Copyright © 2013 Apple Inc. All Rights Reserved.
110
Tutorial: Add Data
Recap
[self.toDoItems addObject:item];
7.
Reload the data in your table.
Because the table view doesn’t keep track of its data, it’s the responsibility of the data source—in this
case, your table view controller—to notify the table view when there’s new data for it to display.
[self.tableView reloadData];
Your unwindToList: method should look like this:
- (IBAction)unwindToList:(UIStoryboardSegue *)segue
{
XYZAddToDoItemViewController *source = [segue sourceViewController];
XYZToDoItem *item = source.toDoItem;
if (item != nil) {
[self.toDoItems addObject:item];
[self.tableView reloadData];
}
}
Checkpoint: Run your app. Now when you click the Add button (+) and create a new item, you should see it
in your to-do list. Congratulations! You’ve created an app that takes input from the user, stores it in an object,
and passes that object between two view controllers. This is the foundation of moving data between scenes
in a storyboard-based app.
Recap
You’re almost done with this introductory tour of developing apps for iOS. The final section gives you more
information about how to find your way around the documentation, and it suggests some next steps you
might take as you learn how to create more advanced apps.
2013-10-22 | Copyright © 2013 Apple Inc. All Rights Reserved.
111
Next Steps
“iOS Technologies” (page 113)
“Finding Information” (page 116)
“Where to Go from Here” (page 128)
2013-10-22 | Copyright © 2013 Apple Inc. All Rights Reserved.
112
iOS Technologies
You’ve just learned how to write an app with a simple user interface and basic behavior. At this point, you may
be thinking about implementing additional behavior that will turn your project into a full-featured app.
As you consider which features you want to add, remember that you don’t have to implement everything from
scratch. iOS provides frameworks that define particular sets of functionality—from gaming and media to
security and data management—which you can integrate into your app. You’ve already used the UIKit framework
to design your app’s user interface, and the Foundation framework to incorporate common data structures
and behavior into your code. These are two of the most common frameworks used in iOS app development,
but there are many more available to you.
This chapter is a high-level overview of technologies and frameworks that you might consider adopting in