Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 该应用程序可以在模拟器上运行,但不能在iPad上运行_Objective C_Ios_Ipad - Fatal编程技术网

Objective c 该应用程序可以在模拟器上运行,但不能在iPad上运行

Objective c 该应用程序可以在模拟器上运行,但不能在iPad上运行,objective-c,ios,ipad,Objective C,Ios,Ipad,我目前正在编写一个应用程序,它使用核心图形在屏幕上移动对象。移动对象后,它会将其位置保存在plist中。加载时,它从plist加载到对象的位置。如果由于某种原因没有plist或无法从plist加载数据,则会加载默认位置。它在模拟器中运行良好,但在iPad上运行时,它会继续加载默认值,即使存在plist。我通过iTunes下载了这些plists,它们已经更新了,但出于某种原因,它没有阅读它们?还有其他人有类似的问题吗 NSString *error = [[[NSString alloc]init

我目前正在编写一个应用程序,它使用核心图形在屏幕上移动对象。移动对象后,它会将其位置保存在plist中。加载时,它从plist加载到对象的位置。如果由于某种原因没有plist或无法从plist加载数据,则会加载默认位置。它在模拟器中运行良好,但在iPad上运行时,它会继续加载默认值,即使存在plist。我通过iTunes下载了这些plists,它们已经更新了,但出于某种原因,它没有阅读它们?还有其他人有类似的问题吗

NSString *error = [[[NSString alloc]init]autorelease];

NSPropertyListFormat format;

NSString *plistName = [[[NSString alloc] initWithFormat:@"nameOfObject%d", [delegate plistSelected]]autorelease];



NSString *plistPath = [[[NSString alloc] init]autorelease];
plistPath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];

    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];


NSDictionary *plistData = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&error];

if(! plistData){

    NSLog(@"error reading the plist: %@ format:%d", error, format);
}

NSArray *arrayOfDictonarys = [[NSArray alloc] initWithArray:[plistData objectForKey:@"DicName"]];

PragamOnce在它的位置是错误的目录。我不知道为什么,但确实如此。我从学校得到了一些代码,纠正了错误

+(NSString*) pathToDocumentsFolder
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return documentsDirectory;  
}
+(NSString*) pathToFileInDocumentsFolder:(NSString*)filename
{
NSString *pathToDoc = [NSBundle pathToDocumentsFolder];
return [pathToDoc stringByAppendingPathComponent:filename];
}
一旦我实现了这段代码,它就可以毫无问题地工作了

谢谢你的帮助


Jake

显示加载plist的代码。听起来像是文件名的大小写问题。该设备区分大小写。我的一个应用程序完全按照您描述的方式工作,没有任何问题。验证您是否正在读取plist并获得预期结果。这是plist加载的问题。请记住,在设备上,您必须将内容保存在documents目录中。感谢您提供的提示,我检查了名称,并且即使在我使用iPad进行调试时,也正在加载plists。它的工作原理与模拟器相同。奇怪你是在ViewController中写这个方法的吗?我在保存和加载声音文件时遇到类似问题。提前谢谢。