Tag: plist

以编程方式编辑plist

我从来没有记住要改变任何东西,所以我只是使用苹果提供的这个方法( https://developer.apple.com/library/mac/qa/qa1361/_index.html ) mdebugging或生产,所以我的所有更改都是为我做的(切换到真正的广告,使用生产url等) 我有以下plist城市飞艇 AirshipConfig.plist <?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>analyticsEnabled</key> <false/> <key>inProduction</key> <false/> <key>developmentAppKey</key> <string>SOMESTRINGHERE</string> <key>developmentAppSecret</key> <string>SOMESTRINGHERE</string> <key>productionAppKey</key> <string>SOMESTRINGHERE</string> <key>productionAppSecret</key> <string>SOMESTRINGHERE</string> </dict> </plist> 现在对于Urban Airship inProduction ,当我发布到应用程序商店时,必须将inProduction更改为true ,当我正在debugging时,将false更改为false 所以在我的应用程序委托,我试图改变plist与以下if。 我仍然试图让plist的内容看到它正在工作,但我一直得到(null)作为我的NSLog if([Def AmIBeingDebugged]){ //Development set to false NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"AirshipConfig" ofType:@"plist"]; NSLog(@"%@", [NSArray […]

在Xcode的Plist里search数组

我正在开发一个应用程序,该应用程序应该searchPlist数据中的string,并返回一个值,以提示用户是什么types的品牌。 例如,用户在我的文本字段中input“iPhone”,应用程序应该点击文本字段下方的“Go”button,返回用户input的产品品牌。 在我的Products.plist里面,它包含品牌的某些产品的品牌arrays。 例子是: 苹果:iPhone,iPod,iPad,Mac索尼:PSP,PS3,Bravia,Xperia三星:Galaxy S II,Galaxy S III,Galaxy Tab 我怎样才能做到这一点? 我已经做了我的应用程序工作正常,但没有使用plist。 我只想使用应用程序的Plist来轻松维护和更新。

从url加载.plist文件

我有下面的代码从资源文件夹加载一个plist文件,并使用它来填充tableview: NSString *path = [[NSBundle mainBundle] pathForResource:@"AnimeDB" ofType:@"plist"]; NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; self.dataList1 = tmpArray; [tmpArray release]; 但我需要从一个URL加载.plist文件。 我尝试了一些我在网上find的解决scheme,但我无法实现它的工作。 有人知道我该怎么做? 也许有一个简单的解决scheme,但我在Xcode的开始(这是我的第一个应用程序),所以我找不到它。 任何帮助真的很感激! PS对不起,我可能犯了任何错误,我的英语不是那么好。

阅读plist文件。 iOS编程

我有这个代码,无法弄清楚我做错了什么。 正如你在下面的代码中可以看到的,我有一个plist文件,名为shifts.plist ,位于我的supporting files夹中。 这是我的plist结构。 NSString *path = [[NSBundle mainBundle] pathForResource:@"shifts" ofType:@"plist"]; dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:path]; cell.textLabel.text = [secondTableInfo objectAtIndex:indexPath.row]; NSLog(@"%@",[[dictionary objectForKey:@"name"]objectAtIndex:0]); 我最终想读取name条目,并与他们填充一个UITableView 。 我用NSLog输出dictionary ,我得到了以下。 所以文件就在那里,只是解决,我错了。 谢谢, 山姆

保存CLLocation错误:发送到不可变对象的变异方法

我已经读了其他相关的问题,但我卡住了。 我正在尝试将最后一个已知位置保存到plist中以备后用。 这是我收到的错误消息: *终止应用程序由于未捕获的exception'NSInternalInconsistencyException',原因:' – [__ NSCFDictionary setObject:forKey:]:mutating方法发送到不可变对象' 这是我的代码: var plist = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Config", ofType: "plist")) var dataToStore = NSKeyedArchiver.archivedDataWithRootObject(lastKnownLocation) plist.setValue(dataToStore, forKey: "location") “lastKnownLocation”var是一个CLLocation。 plist中的“位置”键是“数据”types。 有人可以请帮助,让我知道如何做到这一点(或如果有更好的办法他们如何做)? 谢谢

将数据从plist加载到两个TableViews

我有一些麻烦,从我的属性列表中加载一些数据。 看看…这是我的directory.plist 。 我想在Main.storyboard上显示所有这些,就在这里: 但是, Position e Name将显示在第一个TableViewController上 ,并且键Functionary , ImageFace和Phone必须出现在第二个TableViewController上 。 要做到这一点,我做了这个: 添加到AppDelegate下面: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if let url = Bundle.main.url(forResource: "directory", withExtension: "plist"), let array = NSArray(contentsOf: url) as? [[String:Any]] { Shared.instance.employees = array.map{Employee(dictionary: $0)} } return true 像这样创build一个Struct : struct EmployeeDetails { let functionary: […]

限制IOS中的应用程序function仅适用于Cell / WiFi数据。

我已经search了所有的StackOverFlow,但没有find任何答案如何使用必需的设备function或UIRequiresPersistentWiFi 。 如何在我的应用程序中设置值,以便该应用程序仅适用于iPhone中的蜂窝数据/ WiFi? 目前我已经根据iOSDeviceCompatibility在必需的设备能力数组中设置了stringWiFi属性。 这是正确的方法,还是应该将UIRequiresPersistentWiFi BOOL设置为YES ?

writeToFile无法与NSDictionary工作

我环顾了其他类似的问题,但没有真正起作用。 我设法在我的Plist上只写了一个字典对(对象/键)(例如:setObject:itemProperties [0] forKey [0])。 但是我想要添加所有的物品和钥匙。 我没有pipe理到目前为止(返回错误)。 任何帮助? // Path to Documents Folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"items.plist"]; NSFileManager *fileManager = [NSFileManager defaultManager]; if (![fileManager fileExistsAtPath: path]) { path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"items.plist"] ]; } NSMutableDictionary *items; if ([fileManager fileExistsAtPath: path]) { […]

ObjC Plist文件读取速度比JSON快吗?

我已经做了这个testing项目https://github.com/danielpetroianu/FileDeserializeBenchmarking看看什么是我可以从应用程序包中读取文件的最快方式,并反序列化它。 我很惊讶地看到,Plist文件被读取得比JSON快。 由于JSON文件尺寸较小,我预计它会更快。 Xcode在构build时对Plist文件有一些优化吗? 我做了什么错误导致JSON反序列化需要更多的时间?

NSPropertyListSerialization propertyListWithData产生不兼容的转换警告/错误

我试图从plist中读取数据,使用下面的代码: NSString *error; NSData * tempData = [[NSData alloc] initWithContentsOfFile:@"Data.plist"]; NSDictionary *temp = [NSPropertyListSerialization propertyListWithData:tempData options:NSPropertyListImmutable format:NSPropertyListXMLFormat_v1_0 error:&error]; 它踢出了一个警告/错误,指出: “不兼容整数到指针转换发送'int'到'NSPropertyListFormat'(又名'unsigned int *')types的参数。 我不知道发生了什么事。 我从代码提示select中select了NSPropertyListXMLFormat_v1_0。 另外,到目前为止,在文档中我找不到这样的理由:为什么你必须为“error”声明一个指针variables,然后使用“&error”作为错误的参数: 什么是&符号?