2012-05-09 8 views
7

मेरे पास यह कोड कोरडाटा ऐप में मेरे - (NSPersistentStoreCoordinator *) persistentStoreCoordinator के लिए लिखा गया है। मैं अनुप्रयोग बनाने के लिए Xcode के मास्टर-विस्तार से आवेदन टेम्पलेट का उपयोग किया ...आईएसओ सिम्युलेटर और डिवाइस में NSFileProtectionComplete का परीक्षण

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator 
{ 
    if (__persistentStoreCoordinator != nil) { 
     return __persistentStoreCoordinator; 
    } 

    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Notes2.sqlite"]; 

    NSError *error = nil; 
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { 

     NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
     abort(); 
    }  

    NSString *urlString = [storeURL absoluteString]; 
    NSDictionary *fileAttributes = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey]; 
    if (![[NSFileManager defaultManager] setAttributes:fileAttributes ofItemAtPath:urlString error:&error]) 
    { 
     // Handle error 
    } 


    return __persistentStoreCoordinator; 
} 

मैं कैसे परीक्षण और जानता हूँ कि मेरे SQLite NSFileProtectionComplete चालू की है, कर सकते हैं?

मैंने सिम्युलेटर लॉक किया, लेकिन जब भी मैं फ़ाइंडर में फ़ाइल पर डबल क्लिक करता था तब भी फ़ाइल पठनीय थी।

+0

मैंने डिवाइस को लॉक करके डिवाइस पर लॉन्च करके आईट्यून्स और आईट्यून्स फ़ाइल शेयरिंग का उपयोग करके डिवाइस से फ़ाइल को अपने डेस्कटॉप पर कॉपी करने के लिए भी परीक्षण किया ... लेकिन फ़ाइल अभी भी पठनीय थी। – OscarTheGrouch

+1

क्या आप इसका परीक्षण करने में सक्षम थे? – yoninja

उत्तर

0

iTunes डिवाइस से फ़ाइलों की प्रतिलिपि नहीं करेगा जब तक कि आपका पासकोड न हो या डिवाइस पहले से भरोसा किया गया हो; इस तरह यह डेटा को डिक्रिप्ट करने में सक्षम है।

एक्सकोड 8 में और इससे पहले सिम्युलेटर मेजबान फाइल सिस्टम का उपयोग करता है और मैकोज़ वर्तमान में प्रति-फ़ाइल एन्क्रिप्शन का समर्थन नहीं करता है जैसा कि आईओएस करता है, इसलिए मैकोज़ पर आप सिम्युलेटर में इसका परीक्षण नहीं कर सकते।

संबंधित मुद्दे