Developer Area

Changeset 864 for apps

Show
Ignore:
Timestamp:
07/07/11 12:52:14 (3 years ago)
Author:
henri
Message:

Changed the cache archive handling

Location:
apps/iphone/superbook/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • apps/iphone/superbook/trunk/Classes/LocateThem_AppDelegate.m

    r851 r864  
    2828#import "LocateThem_AppDelegate.h" 
    2929#import "LocateThem_ViewController.h" 
     30#import "TelDomain.h" 
    3031#import "NetworkUtility.h" 
    3132 
     
    4849                } 
    4950                 
     51        // Make sure the domain cache directory exists 
     52        NSString *archivesDirectory = [TelDomain archivesDirectory]; 
     53        [[NSFileManager defaultManager] createDirectoryAtPath:archivesDirectory withIntermediateDirectories:YES attributes:nil error:NULL]; 
     54         
    5055#ifdef DEBUG_REMOTE 
    5156                // Enable remote debug logging for special debugging 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/TelDomain.h

    r851 r864  
    8686- (NSString *)telFromQueryString:(NSString *)query; 
    8787 
     88// utility 
     89+ (void)deleteCachedArchiveForTelName:(NSString *)telName; 
     90+ (NSString *)archivesDirectory; 
     91 
    8892@property (nonatomic, readonly) BOOL isCached; 
    8993@property (nonatomic, readonly) NSString *telName; 
     
    102106@property (nonatomic, assign) id <TelDomainDelegate> delegate; 
    103107 
     108 
    104109@end 
  • apps/iphone/superbook/trunk/DotTel_SDK/Classes/TelDomain.m

    r851 r864  
    3030@interface TelDomain (PrivateMethods) 
    3131- (NSString *)archivePath; 
     32+ (NSString *)archivePathForTelName:(NSString *)telName; 
    3233@end 
    3334 
     
    5960 
    6061// Canonical initializer 
     62// Will use the cache to populate itself if it exists, even if it is expired 
     63// It is up to the caller to decide whether to use the expired data or not 
    6164- (id)initWithTelName:(NSString *)aTelName delegate:(id<TelDomainDelegate>)aDelegate { 
    6265        if ((aTelName == nil) || (aDelegate == nil)) 
     
    8487    } else { 
    8588        // There's a cache, let's use it and regenerate the rest of the data 
    86         // TODO: Make sure delegates use the isCached feature 
    8789        isCached = YES; 
    8890        NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; 
     
    124126    } 
    125127    return result; 
    126 } 
    127  
    128 - (void)deleteCachedArchive { 
    129     [[NSFileManager defaultManager] removeItemAtPath:[self archivePath] error:NULL]; 
    130128} 
    131129 
     
    423421} 
    424422 
     423+ (NSString *)archivesDirectory { 
     424    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
     425    NSString *cachesDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"domains"]; 
     426    return cachesDirectory; 
     427} 
     428 
    425429- (NSString *)archivePath { 
    426     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
    427     NSString *cachesDirectory = [paths objectAtIndex:0]; 
    428     NSString *archivePath = [cachesDirectory stringByAppendingPathComponent:_telName]; 
     430    return [[self class] archivePathForTelName:_telName]; 
     431} 
     432 
     433+ (NSString *)archivePathForTelName:(NSString *)telName { 
     434    NSString *archivePath = [[self archivesDirectory] stringByAppendingPathComponent:telName]; 
    429435    return archivePath; 
    430436} 
    431437 
     438- (void)deleteCachedArchive { 
     439    return [[self class] deleteCachedArchiveForTelName:_telName]; 
     440} 
     441 
     442+ (void)deleteCachedArchiveForTelName:(NSString *)telName { 
     443    [[NSFileManager defaultManager] removeItemAtPath:[self archivePathForTelName:telName] error:NULL]; 
     444} 
     445 
    432446@end 
Telnic
Search This Site
Partners
Neustar
ICANN
Main site | WHOIS | Sell .tel | FAQ | Archived Site | About Telnic | Contact Us