Database Reference
In-Depth Information
The final step is to go back and adjust the
FriendsCollectionViewController
. Open the
FriendsColl
ectionViewController.h
file and add the import for the
FriendDetailViewController.h
file.
#import "FriendDetailViewController.h"
We also need to subscribe to the
FriendDetailViewControllerDelegate
Protocol. Your interface line
should now look like this:
@interface FriendsCollectionViewController : UICollectionViewController <UICollectionViewDataSource,
UICollectionViewDelegate, EntryCollectionViewCellDelegate, UIAlertViewDelegate,
FriendDetailViewControllerDelegate>
Now we need to add the delegate method
detailViewControllerDidClose:
. The only thing
we are doing right now is telling our navigation controller to go to the root controller by calling
popToRootViewControllerAnimated
:. We will do more with this method later.
#pragma mark - FriendDetailViewControllerDelegate Methods
-(void)detailViewControllerDidClose:(FriendDetailViewController *)detailViewController {
[self.navigationController popToRootViewControllerAnimated:YES];
}
Finally, let's update our
prepareForSegue:sender
method so that it looks like this:
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"ToFriendDetails"]){
[[segue destinationViewController] setDelegate:self];
[[segue destinationViewController] setShouldStartEditing:_shouldStartEditing];
}
}
Here we are just assigning our self as the delegate for the
FriendDetailViewController
and sending
our
property _shouldStartEditing
. Remember this is the Boolean value that determines if we
launch the view in edit more or if we are just viewing.
Go ahead and build and run the app. You should be able to add new Friends, delete them if you
long press on them too. You can select an image in the detail view and it will show up in that view.
None of this is being saved yet, but it lays the foundation for us to concentrate solely on integrating
UIDocument
.
UIDocument
UIDocument
is an abstract base class that handles the managing of data and documents.
Subclassing
UIDocument
gives you a lot of things right of the box such as:
Asynchronous reading and writing of data on a background queue.
Coordinated reading and writing of document files already integrated
with iCloud.
Search WWH ::
Custom Search