0

i want to make an application that contains collection of text but in URDU language, i'm confused how to implement it . I've read many posts regarding this but couldn't come to a relevant answer. Please help me regarding this . Thanks in advance

here is my code to fetch data:

+ (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");
}
}
nickAtStack
  • 163
  • 8

1 Answers1

0

that s very easy.

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

then just copy and paste the Arabic Data Of your App in NIB file. or in Strings in Code. Note: In This way user just have to restart App once on First Run.

Imran Ahmed
  • 1,023
  • 1
  • 11
  • 23
  • thanks sir, i'll check it now and let u know… do i have to convert my string encoding or something ? or simple NSString set to textView is fine ? – nickAtStack Oct 24 '13 at 07:51
  • just you have to copy and paste the data in xocde like e.g([[AppManager AppManagerSharedInstance] Show_Alert_With_Title:@"اللغة المختارة" message:@".الرجاء إعادة تشغيل التطبيق"];) – Imran Ahmed Oct 24 '13 at 07:54
  • thank you sir! that did work for alert.. but i still can't show it in text.(sorry for extending the problem) Actually, i have a database written in arabic, i've to show it in text.. but i think the problem is that it doesn't recognise words while fetching text from database . So, all i can see are "???????" only.. could you help me with that sir ..? – nickAtStack Oct 24 '13 at 08:02
  • i'm using this app of stackOverflow it isn't letting me post my code don't know why :( – nickAtStack Oct 24 '13 at 09:44
  • i'm using core data by the way – nickAtStack Oct 24 '13 at 09:45
  • while (sqlite3_step(statement) == SQLITE_ROW) { aObject = [NSEntityDescription insertNewObjectForEntityForName:@"Surah" inManagedObjectContext:context]; aObject.obj_id = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 0) encoding:NSUTF8StringEncoding]; aObject.obj_name = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 1) encoding:NSUTF8StringEncoding]; aObject.number_of_elements = [NSString stringWithCString:(char *)sqlite3_column_text(statement, 2) encoding:NSUTF8StringEncoding]; } sqlite3_finalize(statement); – nickAtStack Oct 24 '13 at 09:47