Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/*
2
 * Copyright 2019 Google
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
#import <Foundation/Foundation.h>
18
 
19
@interface FIRMessagingBackupExcludedPlist : NSObject
20
 
21
/**
22
 *  Caches the plist contents in memory so we don't hit the disk each time we want
23
 *  to query something in the plist. This is loaded lazily i.e. if you write to the
24
 *  plist the contents you want to write will be stored here if the write was
25
 *  successful. The other case where it is loaded is if you read the plist contents
26
 *  by calling `contentAsDictionary`.
27
 *
28
 *  In case you write to the plist and then try to read the file using
29
 *  `contentAsDictionary` we would just return the cachedPlistContents since it would
30
 *  represent the disk contents.
31
 */
32
@property(nonatomic, readonly, strong) NSDictionary *cachedPlistContents;
33
 
34
/**
35
 *  Init a backup excluded plist file.
36
 *
37
 *  @param fileName                       The filename for the plist file.
38
 *  @param subDirectory The subdirectory in Application Support to save the plist.
39
 *
40
 *  @return Helper which allows to read write data to a backup excluded plist.
41
 */
42
- (instancetype)initWithFileName:(NSString *)fileName subDirectory:(NSString *)subDirectory;
43
 
44
/**
45
 *  Write dictionary data to the backup excluded plist file. If the file does not exist
46
 *  it would be created before writing to it.
47
 *
48
 *  @param dict  The data to be written to the plist.
49
 *  @param error The error object if any while writing the data.
50
 *
51
 *  @return YES if the write was successful else NO.
52
 */
53
- (BOOL)writeDictionary:(NSDictionary *)dict error:(NSError **)error;
54
 
55
/**
56
 *  Delete the backup excluded plist created with the above filename.
57
 *
58
 *  @param error The error object if any while deleting the file.
59
 *
60
 *  @return YES If the delete was successful else NO.
61
 */
62
- (BOOL)deleteFile:(NSError **)error;
63
 
64
/**
65
 *  The contents of the plist file. We also store the contents of the file in-memory.
66
 *  If the in-memory contents are valid we return the in-memory contents else we read
67
 *  the file from disk.
68
 *
69
 *  @return A dictionary object that contains the contents of the plist file if the file
70
 *          exists else nil.
71
 */
72
- (NSDictionary *)contentAsDictionary;
73
 
74
/**
75
 *  Check if the plist exists on the disk or not.
76
 *
77
 *  @return YES if the file exists on the disk else NO.
78
 */
79
- (BOOL)doesFileExist;
80
 
81
@end