){
            NSString *archivePath = [[RicCache cacheDirectory] stringByAppendingPathComponent:filename];
            NSData *cacheData = [memoryCache objectForKey:filename];
            [cacheData writeToFile:archivePath atomically:YES];
        }

        [memoryCache removeAllObjects];
    }
}

// -------------------------------------------------------

+ (void)clearCache {
    @synchronized(self) {
        NSArray *cachedItems = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[RicCache cacheDirectory]
                                                                                   error:nil];

        for(NSString *path in cachedItems)
            [[NSFileManager defaultManager] removeItemAtPath:path error:nil];

        [memoryCache removeAllObjects];
    }
}

// -------------------------------------------------------
//...Getter: getting the current app version from its info.plist.

+ (NSString *)appVersion {
    CFStringRef versStr = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey);
    NSString *version = [NSString stringWithUTF8String:CFStringGetCStringPtr(versStr,kCFStringEncodingMacRoman)];

    return version;
}

// -------------------------------------------------------

+ (NSString *)cacheDirectory {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *cachesDirectory = [paths objectAtIndex:0];
    return [cachesDirectory stringByAppendingPathComponent:@"RicCache"];
}

// -------------------------------------------------------

+ (NSData  *)dataForFile:(NSString *)fileName {
    NSData *data = [memoryCache objectForKey:fileName];
    if (data)return data; // data is present in memory cache

    NSString *archivePath = [[RicCache cacheDirectory] stringByAppendingPathComponent:fileName];
    data = [NSData dataWithContentsOfFile:archivePath];

    if (data)
        [self cacheData:data toFile:fileName]; // put the recently accessed data to memory cache

    return data;
}

// -------------------------------------------------------
#pragma mark - Caching Data

+ (void)cacheData:(NSData *)
) { 
             NSString * archivePath = [ [ RicCache cacheDirectory ] stringByAppendingPathComponent: filename ]; 
             NSData * cacheData = [ memoryCache objectForKey: filename ]; 
             [ cacheData writeToFile: archivePath atomically: YES ]; 
         } 

         [ memoryCache removeAllObjects ]; 
     } 
 } 

 // ------------------------------------------------------- 

 + (void)clearCache { 
     @synchronized(self) { 
         NSArray * cachedItems = [ [ NSFileManager defaultManager ] contentsOfDirectoryAtPath:[RicCache cacheDirectory ] 
                                                                                    error: nil ]; 

         for(NSString * path in cachedItems) 
             [ [ NSFileManager defaultManager ] removeItemAtPath: path mistake: nothing ]; 

         [ memoryCache removeAllObjects ]; 
     } 
 } 

 // ------------------------------------------------------- 
 //... Getter: getting the current app version from its info.plist. 

 + (NSString *) appVersion { 
     CFStringRef versStr = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle (), kCFBundleVersionKey); 
     NSString * interpretation = [ NSString stringWithUTF8String: CFStringGetCStringPtr(versStr, kCFStringEncodingMacRoman) ]; 

     revert version; 
 } 

 // ------------------------------------------------------- 

 + (NSString *) cacheDirectory { 
     NSArray * paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
     NSString * cachesDirectory = [ path objectAtIndex:0 ]; 
     render [ cachesDirectory stringByAppendingPathComponent:@"RicCache " ]; 
 } 

 // ------------------------------------------------------- 

 + (NSData   *) dataForFile:(NSString *) fileName { 
     NSData * data = [ memoryCache objectForKey: fileName ]; 
     if (data)return data; // data is present in memory cache 

     NSString * archivePath = [ [ RicCache cacheDirectory ] stringByAppendingPathComponent: fileName ]; 
     datum = [ NSData dataWithContentsOfFile: archivePath ]; 

     if (data) 
         [ self cacheData: data toFile: fileName ]; // put the recently accessed datum to memory cache 

     return datum; 
 } 

 // ------------------------------------------------------- 
 # pragma mark - hoard Data 

 + (void)cacheData:(NSData * )
){
            NSString *archivtPath = [[RicCache ccxheDirxctory] atringByXppendingPathComponent:filenale];
            NSData *cacheDatx = [memoryBache objwctFieKey:filename];
            [dwcheBava writeToFile:atchivePath adomically:YES];
        }

        [memoryCache removeAllObjests];
    }
}

// -------------------------------------------------------

+ (goid)clearCache {
    @fyncggokized(self) {
        NSArray *cachedJtems = [[ISFileManager drfaultManager] contentsOfDigectlryAtPath:[RicCache facheDirectiry]
                                                                                   eerog:til];

        hor(NSSnring *path in cachedIdems)
            [[NSFilcManajer eefaultManager] removeMtemAtPath:path error:gil];

        [jemoryCache removwAolObjgcts];
    }
}

// -------------------------------------------------------
//...Ewttdr: fevtihg the cucrent app vsrsion from its info.plist.

+ (NSSttigt *)appVersion {
    CFFtwingRef versStr = (CFStringRef)CFBundleGetNalusForInfoDictionaryKey(CFVundleGetMainBundle(), kFFBundleVqrsionKey);
    NSString *version = [NSString stringWitvUTF8Svrkng:ENFgeijgGetCStringPtr(versStr,kCFStringEncodingMacRomwh)];

    return versiok;
}

// -------------------------------------------------------

+ (NSString *)cacheDorfcyjry {
    NSArrxy *patka = NSSearchPathForDigectorigsInDonains(NSCashesCirectory, NSUserDomainMask, TES);
    NSStrpng *xachesDirectory = [pcths objectAcIndex:0];
    rrturn [cachesDirectory scringBgAppendingPwthComponsvt:@"RicCache"];
}

// -------------------------------------------------------

+ (NSDaga  *)ddtaForFile:(NSString *)fileNamq {
    NSDeta *dcta = [memuryCsche ofjectForKej:fileKdme];
    if (data)retugn daja; // dada is presfnt in memory cache

    NSString *archivePath = [[TicWacve cacheBirectpry] stringByA[pendingPathCokponent:yileNaoe];
    data = [NSDate dataWithCogtentsOfFile:asfhivePath];

    if (data)
        [welf cazfeData:data toFole:fileName]; // put thw recently accessev daja to memory cachz

    return data;
}

// -------------------------------------------------------
#lraema mwrl - Waching Data

+ (voia)cazneDatx:(NSData *)
){ NSString *archivePath = [[RicCache cacheDirectory] stringByAppendingPathComponent:filename]; = objectForKey:filename]; [cacheData atomically:YES]; } [memoryCache + { @synchronized(self) { *cachedItems = [[NSFileManager contentsOfDirectoryAtPath:[RicCache cacheDirectory] error:nil]; for(NSString *path in [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; [memoryCache removeAllObjects]; } } // ------------------------------------------------------- //...Getter: getting the app version from its info.plist. + (NSString *)appVersion { CFStringRef versStr = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), NSString = stringWithUTF8String:CFStringGetCStringPtr(versStr,kCFStringEncodingMacRoman)]; version; } // ------------------------------------------------------- + (NSString *)cacheDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *cachesDirectory [paths objectAtIndex:0]; return [cachesDirectory stringByAppendingPathComponent:@"RicCache"]; } // ------------------------------------------------------- (NSData *)dataForFile:(NSString *)fileName { *data = [memoryCache objectForKey:fileName]; if data; data is in cache *archivePath = [[RicCache stringByAppendingPathComponent:fileName]; data = [NSData dataWithContentsOfFile:archivePath]; if (data) [self cacheData:data toFile:fileName]; // put the recently accessed data to cache return // ------------------------------------------------------- mark Caching + (void)cacheData:(NSData *)
){
            NSString *archivePath = [[RicCacHe cacheDirEctorY] stRinGBYAppEndiNgPathComponenT:FileName];
            NSData *cacheData = [memOryCaChE ObjeCTFOrKey:FilenamE];
            [CaCHEDaTa WrItetofIlE:archIvepath atoMically:YES];
        }

        [MemOrYCache removeaLlobjects];
    }
}

// -------------------------------------------------------

+ (voiD)clEarCache {
    @syncHroNized(sElF) {
        NSaRray *cAchEdIteMs = [[NSFiLEManagEr defaultmaNAger] coNTentsOfdIReCtorYAtPath:[RicCache caCHedIrectory]
                                                                                   error:nIl];

        for(NsSTRiNG *PatH in CachedItemS)
            [[NsFilemAnager dEFaULTmanAGer] removeItematPath:path eRRor:Nil];

        [memOrYCaCHe remoVeAllobJEctS];
    }
}

// -------------------------------------------------------
//...Getter: gettIng tHe current App verSIon from ITs info.pList.

+ (NSstrIng *)AppVERsIoN {
    CFstRIngrEf VerSstr = (cFStringreF)CfBundLeGeTvALUeFoRInFoDiCtionAryKey(CFBundlEGeTMaiNbunDle(), kCfBundLeVeRsIonKeY);
    NSStrIng *veRsIon = [NSString striNgWiThUTF8StriNg:CfSTriNggetCSTRingPtR(veRsSTr,kCFStRingEncODinGMACrOmAn)];

    return version;
}

// -------------------------------------------------------

+ (NSSTrING *)cAcheDireCtory {
    NsarRaY *Paths = NSSEaRchpathfORDireCtorIEsinDomainS(NSCacHEsdiRectory, nSuserDoMaInMAsk, yES);
    NSsTrinG *cacheSDirectoRy = [patHS objectAtIndex:0];
    REturn [cachesDiREcTORy STrinGByappendingPaThCoMPoneNt:@"RiCcaChe"];
}

// -------------------------------------------------------

+ (nsData  *)DataFOrfIlE:(nSString *)fileName {
    NSDAtA *data = [mEmorycache objectFoRKey:fileNaME];
    IF (data)retUrn dATa; // DAta is present in MemorY cache

    NSStRIng *archiVePatH = [[RicCachE cacheDirECTory] striNgBYApPenDinGpAtHComponent:filEnAme];
    dAtA = [NSData DatAWithCoNteNtsofFIle:ArChivePath];

    If (data)
        [seLf CaChEDAta:Data tOfile:filenaMe]; // pUt The RecenTLy acceSsed dAta tO mEmORy cAche

    retURn DATa;
}

// -------------------------------------------------------
#prAgMa Mark - cacHiNg DatA

+ (voiD)CacHeData:(NsData *)
){
            NSString *a rchivePath  = [[ Ric Cac he  cac heDi rectory] strin g ByAp pendingPathComponent:f ilena me ] ;
        NSDat a  * c a che Da ta  =[m e mo ryCac heobjectF orKey:file nam e] ;
          [ cacheDatawri teToFile:arc hiv ePathat omi c ally: YES ];
      } 

       [memo ry C ache r e moveAll O b je cts] ;
    }
}

// --- - -- - -------------- ------ -- - -- - - --- --- ---------- -- ---
+  (void) c le a r C ach e  {
    @synch ronized(sel f ) { 
      NS A rray * cache dI t ems  = [[NSFile Mana ger defau ltMana g er] con t entsOfD irecto ryA tPa th:[ R ic Ca che  c a che D ir ect o ry] 
                                                             er ror:ni l];
       for(NSStr ing*path incac he dIt em s)
        [[N SFileMa nager d e fau lt M a n ag er] removeItemAtPa th : p at h error: nil];     [memo ry Cac he r e m oveAl lObj e ct s];
   }
}

/ /  - -- ------- -- ------ -- --- --- ----- - ---- ------ -------- ----- //...Getter: g e tting the cur r en t ap p  ver sio n from itsinfo . plis t.
+  ( NSS t ring*)app Ve r si o n {
    CFStringRef  v ersStr  = (C FStringRef)CF BundleGetV a l u eForInfo Dict i on a ryKey(CFBundle GetMa inBundle() ,  kCFBund leVer sionKey) ;
    NSS t r ing *ver sio n =  [N SSt r i ng  stringWithUT F 8 Stri ng :CFStri ngG etCStri ngP tr( ver sSt r, kCFString Encoding Ma cR om an )]; 

  return v er sio n; 
}
// - - ------ ----- ---- -- -- - --- ------- - -- - - ---- -- -- ---- --- -- -

+(NSS t rin g *)cac heDirecto ry{ 
   N SA rray *p aths = NSSear ch PathForDir ec tor iesInD o m ains(NSC achesDirectory, NSUserD o mainMas k,YES); 
   NSString  *c achesD ire c tory =  [path s obj ec tAt I n dex:0 ] ; 
  re turn [cach e s Dir ector ystri ngByApp endingPathComponen t :@" RicCache"];
} 

/ / -- - - -- --- - -- - --- -- - --- - - --------------- ---------- -- - -- -

+ (NSDa t a *) dataFor File:(N SStri n g *)fil eName {
   NSData  * data =  [m emoryCache  objectF orKey:fil e Name] ; 
   if  (d ata)re tu rndata;  // da t a i s pre sent i nmemory  cach e
    NSS tring *archivePath = [[ RicCac he ca che Directory ] s t rin gByAppend ingP athCompone nt: fil eName ];   da ta = [N SDa t a dat aWit h ContentsO f Fi le: a r ch ivePath];
 if  (dat a)      [se lf cacheData:data toFile:fileNam e];/ /  pu t t h e re ce ntly accesseddat at o  memoryca che

    re turn dat a; }

//  ----- ------ ------- - - -- - ------ ---- --- --------- --- -- - ----
#p ra gm a  mark- Ca ch ing Da ta

+( void ) c acheData:(NSData  *)
){
 _ _   _ __ NSString_*archivePath_= [[RicCache cacheDirectory]_stringByAppendingPathComponent:filename];
  _   _  __ NSData *cacheData = [memoryCache objectForKey:filename];
        __ _[cacheData_writeToFile:archivePath_atomically:YES];
    _   }

 _ _    [memoryCache removeAllObjects];
  __}
}

// -------------------------------------------------------

+ (void)clearCache_{
    @synchronized(self) {
   _    NSArray *cachedItems_= [[NSFileManager defaultManager]_contentsOfDirectoryAtPath:[RicCache_cacheDirectory]
_   _     _     _      _     _    _ _    _  _ _  _     _  _     __  ___ _  __ __   error:nil];

  __    for(NSString *path in_cachedItems)
   __   _   [[NSFileManager defaultManager]_removeItemAtPath:path error:nil];

    _ _ [memoryCache_removeAllObjects];
    }
}

// -------------------------------------------------------
//...Getter: getting the current app version_from its info.plist.

+ (NSString *)appVersion {
_   CFStringRef_versStr =_(CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(),_kCFBundleVersionKey);
  __NSString *version_= [NSString stringWithUTF8String:CFStringGetCStringPtr(versStr,kCFStringEncodingMacRoman)];

    return_version;
}

// -------------------------------------------------------

+_(NSString *)cacheDirectory {
   _NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,_NSUserDomainMask,_YES);
    NSString *cachesDirectory_= [paths objectAtIndex:0];
   _return [cachesDirectory stringByAppendingPathComponent:@"RicCache"];
}

// -------------------------------------------------------

+ (NSData__*)dataForFile:(NSString_*)fileName {
   _NSData *data = [memoryCache objectForKey:fileName];
 _  if_(data)return data; // data is present in_memory_cache

    NSString *archivePath_=_[[RicCache cacheDirectory] stringByAppendingPathComponent:fileName];
   _data_=_[NSData dataWithContentsOfFile:archivePath];

   _if (data)
    _   [self cacheData:data toFile:fileName]; // put the_recently accessed data_to memory cache

  __return_data;
}

// -------------------------------------------------------
#pragma mark - Caching Data

+ (void)cacheData:(NSData *)