Database Reference
In-Depth Information
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive:)
name:UIApplicationDidBecomeActiveNotification object:nil];
[_query enableUpdates];
}
When we add ourselves as the observer we are telling NSNotificationCenter that we want to call
our method didBecomeActive: . Let's write that now.
-(void)didBecomeActive:(NSNotification *)notification {
[self reload];
}
Here we just call reload when our application becomes active with this screen visible. Now we need
to remove ourselves as the observer and disableUpdates on our NSMetadataQuery object in the
viewDidDisappear: method.
-(void)viewDidDisappear:(BOOL)animated {
[_query disableUpdates];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
You may be wondering why we call enableUpdates and disableUpdates in viewWillAppear : and
viewDidDisappear :, respectively. We do this to stop our query from firing updates if our view is not
visible. This conserves system resources and is responsible programming on our part.
We are done with our programming portion, but we do need to configure our app to handle our ict
file extension by defining a document type and a UTI.
1.
To do this we need to select our project in the Project Navigator, then select
the Info tab in the main window. You will see a section for Document Types.
Expand that section and add a new document type by clicking the + button.
2.
Set the Name to “iCloudTest Document”. Set types to the bundle identifier
you created earlier and append a .doc to it. For example mine is com.
appmosphereinc.icloudtest.doc.
3.
Now expand the additional document type properties by clicking the caret.
Click in the box to add a property.
4.
The first property we add is of type Boolean and is called
“LSTypeIsPackage.” Set it to YES.
5.
Next, add an array and label it “CFBundleTypeExtensions.” Expand the array
by clicking the caret and then click the + to add an item in the array. The item
should be a string with a value of “ict.”
 
Search WWH ::




Custom Search