English 中文(简体)
当地保存的数据档案在推介器中一直存在,但并不在真正的iPad装置中。 Im
原标题:Locally saved data files are persistant in the emulator but not in the real iPad device... I m lost

I m a (kind of) newbie XCode programmer (well, 我想说的是,现在并不如此新的bie presentadays......) 和“my pet issue”是: ,“如果在我真正的iPad上出现麻烦,则把当地档案保存起来,而“”。

坦率地说,我对地方档案没有任何问题,但retrieving。 为什么? 由于在模拟材料中,我的当地档案似乎在汇编会议之间一直存在,但在实际装置上,每当申请启动时(不仅从X条码上载,而且通常发射),“文件”目录中的数据似乎消失了......。 因此,最后用户无法在闭会期间储存所需的历史数据。

Is it a perception of mine? Is it normal behaviour?

用于拯救这一“适当”数据的标准一是:

NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDir = [paths objectAtIndex:0];
NSString *finalPath=[NSString stringWithFormat:@"%@/%@", documentsDir, path];
NSLog(@"Course.m: updatePersistentObject (to disk): final file = %@",finalPath);
[NSKeyedArchiver archiveRootObject:newObject toFile:finalPath];

途径变量为@”。

代码一用于检索数据(无论是在boot时间还是操作时间),是:

NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSLog(@" historical data: Documents paths = %@", paths);      

NSString * docsDir = [paths objectAtIndex:0];
NSLog(@"Course.m: loadHistoricalResultsData: docsDir vale [%@]", docsDir);

NSString *tmpPath=[NSString stringWithFormat:@"%@/.HistoricalTestResults", (NSString *)docsDir];
NSLog(@"Course.m: loadHistoricalResultsData: tmpPath vale [%@]", tmpPath);

NSFileManager *localFileManager = [[NSFileManager alloc] init];

// create directory if it doesn t exist, don t do anything if it exists... (?)
[localFileManager createDirectoryAtPath:tmpPath withIntermediateDirectories:YES attributes:nil error:nil];
NSDirectoryEnumerator *dirEnum = [localFileManager enumeratorAtPath:tmpPath];

NSString *file;    

while (file = [ dirEnum nextObject])
{
    NSLog(@"Historical Data Folder: %@", file);
    if ( [[file pathExtension] compare:@"dat"] == NSOrderedSame  )
    {
        NSString *filePath = [NSString stringWithFormat:@"%@/%@", tmpPath, file];
        NSLog(@"Course.m: loadHistoricalResultsData: filePath vale [%@]", filePath);
        mHistoricalTestList=[[NSKeyedUnarchiver unarchiveObjectWithFile:filePath] retain];
    }
}
[localFileManager release];

My exact problem is that while on the simulator, AT BOOT TIME, if I put a trace on the "while" code line, I can see how the enumerator gets some value, and I can iterate among the found files. On the other hand, when using my iPad, the same breakpoint yields a "nil" pointer when obtaining the enumerator.

As I said, at the beginning of a clean program session, this is normal, so then I need to generate some storable results inside my program memory to store them onto disk. I do it, and then I write them (both inside the simulator and the iPad). Then I can even re-retrieve this data (from disk) and it seems to still exist inside the Documents folder (both onto the iPad and the simulator).

但是,如果我结束/选择方案,这种数据似乎在真实的iPad上消失,并且保留在模拟器中。

With this behaviour, my only deduction is "Real iPad programs cannot store persistent data onto their Documents directory". Am I right? (Of course not, because I ve seen it work on some other programs). So I have the feeling I m doing something wrong, and after wasting TONS of time trying to find it, I m now asking for advice on stackoverflow...

每次帮助/帮助/帮助/帮助/帮助都不会受到欢迎。

最佳回答

我很高兴! 我能够解决我自己的问题(!!)?

我发现,在我最初复制我的两部法典,特别是“阅读部分”时,我照我的实际法典看,字面照照照照照抄,我刚刚改编了一些变称,并补充了这里重要的字眼。 (实际情况)

我甚至做了一些事情,只是“去除一些无关的法典”(这里是重要部分),因为我重新排列了其中一些。 我重新排列的一个部分是:

NSFileManager *localFileManager = [[NSFileManager alloc] init];

NSString *tmpPath=[NSString stringWithFormat:@"%@/.HistoricalTestResults", (NSString *)docsDir];

NSDirectoryEnumerator *dirEnum = [localFileManager enumeratorAtPath:tmpPath];
// create directory if it doesn t exist, don t do anything if it exists... (?)
[localFileManager createDirectoryAtPath:tmpPath withIntermediateDirectories:YES attributes:nil error:nil];

我改动的(在此张贴时)内容已移至另一部分(行之有效):

NSString *tmpPath=[NSString stringWithFormat:@"%@/.HistoricalTestResults", (NSString *)docsDir];

NSFileManager *localFileManager = [[NSFileManager alloc] init];    
// create directory if it doesn t exist, don t do anything if it exists... (?)
[localFileManager createDirectoryAtPath:tmpPath withIntermediateDirectories:YES attributes:nil error:nil];
NSDirectoryEnumerator *dirEnum = [localFileManager enumeratorAtPath:tmpPath];

这背后有一些逻辑,因为“在第一部分时,在推介器上的工作,但在实际装置上是没有的”。 看来,“准确的目录”在某种程度上是“重新确定”某些内部结构,或者在没有创建目录的情况下,可能要求统计员。

无论情况如何,我认为我的经验足以使我能在这里为将来可能处于我状况的人贴上这一句子!

Greetings again!

问题回答

我可以想到的是,你们的用料没有在同一个沙箱上安装。 这意味着,虽然在模拟器中,你的道路是一样的,文件副本载有同样的数据,但您的表板为安装创造了新的目录道路,因此,你在上届会议上坚持的数据是可以获得的。

我所经历的另一个问题是,模拟器在装上资源时缺乏敏感度,而实际上这种装置是敏感的。 当时,我有一份延期文件。 强硬派和麦克风正在寻找。 模拟器将发挥作用,但电话显示在要求采用当地化标准时的关键。

因此,tl;dr:核实不同会议的道路是一样的,你的档案名称是吻合的。

我希望它能够提供帮助。 good!

PS: Gaudí rlz。





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...