concept new LioN in category ios

appears as: new LioN
Anyone Can Create an App: Beginning iPhone and iPad programming

This is an excerpt from Manning's book Anyone Can Create an App: Beginning iPhone and iPad programming.

You finally get to use the Lion class to add data to the array. This is exciting, isn’t it? You need to create a new LioN object, set its properties, and then add it to the lionData array. You’re going to create the new LioN in the viewDidLoad() function, because this function is called before the table view gets set up (go back to chapter 13 if you need a refresher on the ViewController lifecycle).

Why did you add the ? at the end of the LioN? Remember that the ? signifies to Xcode that this variable is optional, and it may or may not be nil. You know this variable will be nil when the user creates a new LioN and this class is called; but you want it to not be nil when the user wants to edit a LioN, so optional is the perfect solution.

23.1.5. Saving the LioN when the user taps Done, but not creating a new LioN

How do you think you can send the updated LioN object back to the MainView-Controller so it can be edited instead of saved as a new object? Right now, when the user taps Done, you’re using the delegate pattern for didFinishAddingItem and passing the data for the new LioN back. If you thought of using a delegate to pass the edited item back, you get a cookie. (I can’t give you a cookie, but consider this permission to go eat a cookie.)