当应用程序处于后台状态时,是否可以读取或写入plist?从后台更新plist
0
A
回答
1
当应用程序处于后台时,不能读取plist,因为您的应用程序在后台状态下运行时间不超过10分钟。只有三个选项可让您的应用程序在后台运行超过10分钟。
如果您要读写plist,请在应用程序进入前台状态时执行此操作。为此,您可以在应用程序中读取和写入您的plist成为活动委托方法。
+0
请不要对“你”和“是”使用“u”和“r”。 Textspeak阅读很痛苦。 –
1
试试这个..
- (void)readPlist
{
NSString *filePath = @"/System/Library/CoreServices/SystemVersion.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
NSString *value;
value = [plistDict objectForKey:@"ProductVersion"];
/* You could now call the string "value" from somewhere to return the value of the string in the .plist specified, for the specified key. */
}
- (void)writeToPlist
{
NSString *filePath = @"/System/Library/CoreServices/SystemVersion.plist";
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
[plistDict setValue:@"1.1.1" forKey:@"ProductVersion"];
[plistDict writeToFile:filePath atomically: YES];
/* This would change the firmware version in the plist to 1.1.1 by initing the NSDictionary with the plist, then changing the value of the string in the key "ProductVersion" to what you specified */
}
希望这可以帮助你!
相关问题
- 1. 从后台更新UIProgressView
- 2. 从后台更新前台活动
- 3. UITableView不是从plist更新
- 4. 从后台加载url的大plist
- 5. 从LaunchAgent plist的后台运行文件?
- 6. Android后台更新
- 7. 从后台线程更新UI控件
- 8. 从后台更新UI线程
- 9. 从后台工作人员更新UI
- 10. 从后台线程更新BindingList <>?
- 11. 从后台线程更新GEF模型
- 12. 从多个后台线程更新UI
- 13. 从后台任务中更新android UI
- 14. 从后台接收器更新Widget
- 15. 从后台线程更新UI
- 16. 从后台线程更新表视图?
- 17. 从后台更新ObservableCollection工作人员
- 18. 从后台线程问题更新UI
- 19. 从plist获取更新的数据
- 20. 将文本从UITextView更新到Plist
- 21. 如何从后台服务更新ViewModel的LiveData并更新UI
- 22. 在后台更新NSManagedObjects
- 23. UI不更新后台bean
- 24. 在后台更新数据
- 25. 停止CoreLocation后台更新
- 26. UIProgressView更新后台线程
- 27. Android后台位置更新?
- 28. Leap Motion JS - 后台更新
- 29. 自jvm后台更新
- 30. 后台位置更新
如果有人对此有任何想法,请回复。 – Siddharth