English 中文(简体)
列入X条码制作名单
原标题:plist in Xcode creation
最佳回答

Here is the final solution that i got for plist....

When u are creating your plist file with first element as Array.. then its XML Contents will be as below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Root</key>
    <array>
        <string>Firecracker</string>
        <string>Lemon Drop</string>
        <string>Mojito</string>
    </array>
</dict>
</plist>

Here you are having unnecessary tag instead of which we should have as your root element must be Array... because u are taking in NSMutableArray object...

so your plist file must be like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <array>
        <string>Firecracker</string>
        <string>Lemon Drop</string>
        <string>Mojito</string>
    </array>
</plist>

i have checked that its working fine....

问题回答

The problem could be

  1. The file doesn t exist at specified path, you get nil in array2.
  2. The file exists but it cannot be read correctly, due to some format corruption, and you get nil in array2 too.
  3. The file exists and its format is correct, but there are no values in, you get an empty array.

在使用<代码>NSString *path = [[NSBundle mainBundle] pathForResource:@“DrinkArray” ofType:@“plist”]; 假设你在你的 app子内有一个名为“DrinkArray”的正确编造的候选人名单(Array.plist)。 你们的档案也抄录在旁边(Xcode中,点击你的项目,然后打造阶段,你的文件应登在Rod Bundle Ressources上)。

我猜测你将<代码>nil作为查阅档案的途径,因此,见array 2。 ry弄你的道路,检查。

我认为,你可以尝试这样的事情:

    NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
    NSMutableArray *array = [dict objectForKey:@"Root"];

    // Show the string values  
    for (NSString *str in array)
    {
        NSLog(@"--%@", str);
    }

如果得到帮助,请下一条线:

Cheers, Kamil

在xcode 5 >中,确保档案存放在贵国的汇编来源区。 “entergraph





相关问题
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 ...

热门标签