I am Fetch JSON data using NSURLSession
Class. but, I am unable to insert,update,delete JSON Objects runtime. Please any one guide me with suitable example and flow. Thanks in advance.
我使用NSURLSession类获取JSON数据。但是,我无法插入,更新,删除JSON对象运行时。请任何人用合适的例子和流程指导我。提前致谢。
1 个解决方案
#1
0
Try using Realm and JSON.. or save JSON strings to file like this
尝试使用Realm和JSON ..或将JSON字符串保存到这样的文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
NSError *error;
BOOL succeed = [myJSONObject writeToFile:[documentsDirectory stringByAppendingPathComponent:@"object-id.json"]
atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!succeed){
// Handle error here
}
#1
0
Try using Realm and JSON.. or save JSON strings to file like this
尝试使用Realm和JSON ..或将JSON字符串保存到这样的文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
NSError *error;
BOOL succeed = [myJSONObject writeToFile:[documentsDirectory stringByAppendingPathComponent:@"object-id.json"]
atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!succeed){
// Handle error here
}