2011-12-12 86 views
0

实际上,如果我将plist添加到资源文件夹,它可以正常工作。但是,如果我创建一个文件夹并将plist添加到该文件夹​​,它不起作用。
任何人都可以帮助我吗?我对cocos 2d和plist都是全新的。如何为plist提供路径名?

+0

怎么不起作用?请提供更多详细信息或代码,以便我们能够提供帮助以及发生什么? - 如果你的plist文件没有被创建 - 如果是,那么请检查使用断点天气数组或者你写给plist的字典是否被分配? – Dhawal

回答

0

获取资源路径后添加您的文件夹名称。

+0

Ya of course Ayaz ..但是它不能从plist中获取相应的图像。它的崩溃显示文件未找到错误。 – user1093287

+0

你可以显示你的代码吗? –

0

使用:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

NSString *documentsDirectory = [paths objectAtIndex:0]; 

plistpath = [[NSString alloc] initWithString:[documentsDirectory stringByAppendingPathComponent:@"Product.plist"]]; 

然后

[array writeToFile:path atomically:YES]; 

[Whatever [Array or Dictionary] you want to Write in Plist] 

,并获取数据从plist中

NSmutableArray *Yourarray = [[NSMutableArray alloc] initWithContentsOfFile:plistpath];