0

我想制作一个包含文本集合但使用 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");
}
}
4

1 回答 1

0

这很容易。

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
    [[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects:@"ar", nil] forKey:@"AppleLanguages"];
   }

然后只需将应用程序的阿拉伯语数据复制并粘贴到 NIB 文件中即可。或在代码中的字符串中。注意:这样用户只需在首次运行时重新启动应用程序一次。

于 2013-10-24T07:47:32.350 回答