我想制作一个包含文本集合但使用 URDU 语言的应用程序,我很困惑如何实现它。我已经阅读了很多关于此的帖子,但无法得出相关的答案。请帮我解决这个问题。提前致谢
这是我获取数据的代码:
+ (void) fetchData:(NSManagedObjectContext *)context
{
NSString *dbFilePath = [[NSBundle mainBundle] pathForResource:DATABASE_NAME ofType:@"sqlite"];
sqlite3 *database;
if (sqlite3_open([dbFilePath UTF8String], &database) != SQLITE_OK)
NSLog(@"sqlite3_open: failed");
else
{
NSString *nsquery = [[NSString alloc] initWithFormat:@"SELECT * FROM myTable"];
const char *query = [nsquery UTF8String];
sqlite3_stmt *statement;
int prepareCode = sqlite3_prepare_v2(database, query, -1, &statement, NULL);
if(prepareCode == 0) {
myClass *aObject;
while (sqlite3_step(statement) == SQLITE_ROW)
{
aObject = [NSEntityDescription insertNewObjectForEntityForName:@"myClass" inManagedObjectContext:context];
aObject.surah_id = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 0) encoding:NSUTF8StringEncoding];
aObject.arabic_name = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 1) encoding:NSUTF8StringEncoding];
aObject.number_of_ayaat = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 2) encoding:NSUTF8StringEncoding];
}
sqlite3_finalize(statement);
}
NSError *error = nil;
if (![context save:&error])
NSLog(@"error occured while saving: %@",error.description);
NSError *err;
NSFileManager *filemgr = [[NSFileManager alloc] init];
[filemgr removeItemAtPath:dbFilePath error:&err];
NSLog(@"Deleted sqlite3 database");
}
}