arrayWithContentsOfFile with plist返回5.1 iPad上的部分键

时间:2012-12-18 11:37:21

标签: iphone objective-c ios nsarray plist

我有以下方法读取plist文件[参见附件截图]并将其作为可变数组返回:

+(NSMutableArray *)getSharersPlistArray:(NSString*)plist
{
    NSString *AppDetailPlist = [[NSBundle mainBundle] pathForResource:plist ofType:@"plist"];
    NSMutableArray* toReturn = [NSMutableArray arrayWithArray:[NSArray arrayWithContentsOfFile:AppDetailPlist]];
    NSLog(@"toReturn:%@", toReturn);
    return toReturn;
}

iPad 1 / iOS 5.1上的不完整结果:

(
        {
        2 =         {
            image = "Icon-72.png";
            name = Email;
            type = ShareCell;
        };
    },
        {
        0 =         {
            image = "Icon-72.png";
            name = Share;
            type = ShareCell;
        };
    }
)

在5.1或6.0模拟器上的正确/完整结果:

(
        {
        0 =         {
            image = "Icon-72.png";
            name = Facebook;
            type = ShareCell;
        };
        1 =         {
            image = "Icon-72.png";
            name = Twitter;
            type = ShareCell;
        };
        2 =         {
            image = "Icon-72.png";
            name = Email;
            type = ShareCell;
        };
    },
        {
        0 =         {
            image = "Icon-72.png";
            name = Share;
            type = ShareCell;
        };
        1 =         {
            image = "Icon-72.png";
            name = Follow;
            type = ShareCell;
        };
    }
)

我确实验证了plist,它看起来没问题:

找到。 -name'* plist'-exec plutil {} \;

./ Share.plist:好的

任何想法为什么?我将不胜感激任何见解)

enter image description here

1 个答案:

答案 0 :(得分:0)

试试这个:

  1. 清理您的Xcode项目;

  2. 从iPad 1 / iOS 5.1设备中删除应用程序。

  3. 重新构建/运行。

    希望这可以解决它。