Archive for the ‘Iphone’ Category

Unlock i4s SoftBank carrier IOS 8.1.2 & fix ussd services

January 5, 2015 Leave a comment

Here the step by step to unlock my iPhone 4S 32G SoftBank carrier IOS 8.1.2 and fix ussd services (ex: to check current balance with command *111# or Internet quota *123#)

  1. Purchase R-sim 9 Pro
  2. Check whether it worked on current iOS version (in my case it worked with ios 5.1.1)
  3. Download & Install the latest iTunes version
  4. Backup iphone data with iTunes
  5. Update current ios version to ios 8.1.2 with iTunes  (need to RESTORE & update if device has been jailbreak before)
  6. Just cancel if there is “carrier settings update” popup
  7. Download & jailbreak with TaiG v1.2.0 (check cydia & uncheck 3K Assistant options)
  8. Reboot
  9. Run cydia and add following repo
  10. Search and Install “CommCenter patch for iOS 7” & “iFile”
  11. Run iFile and go to folder /System/Library/Carrier Bundles/iPhone/Default.bundle/
  12. Select on carrier.plst and select “Property List Viewer”
  13. Scroll down and find the item “SupportsSupplementaryServicesOver3GPP” And turn it “On”
  14. Reboot
  15. Test
Categories: Iphone

Accessing SQLite3 database in Objective-C

November 19, 2012 1 comment

Today I will show you how to access sqlite3 database with objective-C. I use XCode 4.4.1. First thing todo is to add sqlite3 library (libsqlite3.dylib) to  framework directory in your project.

Then write the interface file ViewController.h:

#import <UIKit/UIKit.h>
#import <sqlite3.h>

@interface ViewController : UIViewController
  sqlite3 *db;

-(NSString *) filePath;
-(void) openDB;
-(void) createTableNamed:(NSString *) tableName
withField1:(NSString *) field1
withField2:(NSString *) field2;

-(void) insertRecordIntoTableNamed:(NSString *) tableName
withField1:(NSString *) field1
field1Value:(NSString *) field1Value
withField2:(NSString *) field2
field2Value:(NSString *) field2Value;

-(void) getAllRowsFromTableNamed:(NSString *)tableName;

and then implement methods in ViewController.m:
1. filePath: this method returns the full path of the database that will be created in the Documents folder within apllication’s sandbox

-(NSString *) filePath

    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
    NSString *documentDir = [path objectAtIndex:0];
    return [documentDir stringByAppendingPathComponent:@"database.sql"];


2. openDB: this method will open the database or create database if database is not exists

-(void) openDB
    if(sqlite3_open([[self filePath] UTF8String], &(db)) != SQLITE_OK)
        NSAssert(0, @"Database failed to open");

3. createTableNamed: this method will create table if table is not exists

-(void) createTableNamed:(NSString *) tableName
              withField1:(NSString *) field1
              withField2:(NSString *) field2
    char *err;
    NSString *sql = [NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS '%@' ('%@' TEXT PRIMARY KEY,'%@' TEXT);", tableName, field1, field2 ];

    if(sqlite3_exec(db, [sql UTF8String], NULL, NULL, &err) != SQLITE_OK )
        NSAssert(0, @"Table failed to create");


4. insertRecordIntoTableNamed: this method will insert or replace records

-(void) insertRecordIntoTableNamed:(NSString *)tableName withField1:(NSString *)field1 field1Value:(NSString *)field1Value withField2:(NSString *)field2 field2Value:(NSString *)field2Value
    char *err;
    NSString *sql = [NSString stringWithFormat:@"INSERT OR REPLACE INTO '%@' ('%@','%@') VALUES ('%@','%@') ; ", tableName, field1, field2, field1Value, field2Value ];
    if(sqlite3_exec(db, [sql UTF8String], NULL, NULL, &err) != SQLITE_OK  )
        NSAssert(0, @"Error Inserting/Updating Table");

5. getAllRowsFromTableNamed: this method will retrieves records

-(void) getAllRowsFromTableNamed:(NSString *)tableName
    NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@", tableName];
    sqlite3_stmt * statement;

    if(sqlite3_prepare_v2(db, [sql UTF8String], -1, &statement, nil) == SQLITE_OK)
        while(sqlite3_step(statement) == SQLITE_ROW)
            char *field1 = (char *) sqlite3_column_text(statement, 0);
            NSString *field1Str = [[NSString alloc] initWithUTF8String:field1];
            char *field2 = (char *) sqlite3_column_text(statement, 1);
            NSString *field2Str = [[NSString alloc] initWithUTF8String:field2];

            NSString *str = [[NSString alloc] initWithFormat:@"%@ - %@", field1Str, field2Str];


To test it, insert some code in viedDidLoad method:

    [self openDB];
    [self createTableNamed:@"Contacts"

    for(int i=0; i<5; i++)
        NSString *name = [[NSString alloc] initWithFormat:@"User%d", i];
        NSString *email = [[NSString alloc] initWithFormat:@"", i];

        [self insertRecordIntoTableNamed:@"Contacts"

    [self getAllRowsFromTableNamed:@"Contacts"];
    [super viewDidLoad];

The Output :

2012-11-19 19:59:15.549 Databases[4388:c07] User0 -
2012-11-19 19:59:15.552 Databases[4388:c07] User1 -
2012-11-19 19:59:15.552 Databases[4388:c07] User2 -
2012-11-19 19:59:15.553 Databases[4388:c07] User3 -
2012-11-19 19:59:15.553 Databases[4388:c07] User4 -

Downgrade from ios 5 to ios 4.2.1 (Untethered)

November 3, 2011 1 comment

Things need to be prepared :

  1. Tiny Umbrella 5.00.12
  2. GreenPois0n 1.0 RC6.1
  3. fixrecovery-osx for 4.2.1
  4. ios 4.2.1 ipsw

Follow this step :

  1. Make sure that you have backup SHSHs before
  2. Open TinyUmbrella, and start TSS Server
  3. Make sure that you see SHSHs for ios 4.2.1 in List “All saved SHSHs”
  4. Enter DFU Mode
  5. Start iTunes 10.1
  6. Restore ios 4.2.1 by pressing alt button and click Restore button
  7. Find and Select ios 4.2.1 ipsw
  8. Wait until iTunes finish the process
  9. Maybe there will be an error
  10. Enter DFU mode
  11. Run FixRecovery
  12. Wait until iPhone successfully Reboot
  13. run GreenPois0n
  14. Done

Good Luck

Categories: Iphone, Mac Os

IPhone App Dev. Tutorial 1 : Simple Interaction with Button and Text

August 21, 2011 2 comments

This tutorial show simple interaction with button and text. I used XCode 4.

1. Create New Project > View-based Application

2. Type Product Name, here i typed “ButtonAndText”

3. Click file “ButtonAndTextViewController.xib”

4. Drag and Drop UIButton from Object Library to View, and Type button title, for example “OK”

5. Open header file “ButtonAndTextViewController.h”, and add following code (just add the bold text) :

#import <UIKit/UIKit.h>

@interface ButtonAndTextViewController : UIViewController {
-(IBAction) btnClicked:(id) sender;

6. Open implementation file “ButtonAndTextViewController.m” and type following code after “@implementation ButtonAndTextViewController” :

-(IBAction) btnClicked:(id) sender {
 NSString *str = [[NSString alloc] 
           initWithFormat:@"Welcome Mr. %@ ", textName.text];
 UIAlertView *alert = [[UIAlertView alloc]
                      message:@"Welcome Mr. Tonny"
                      delegate:self cancelButtonTitle:@"OK"
 [alert show];
 [alert release];

7. Click file “ButtonAndTextViewController.xib”

8. While pressing Control-Key, Click on the “OK” Button and drag to the “File’s Owner”, then select “btnClicked”

9. Then try running the program, the output should like this :

10. Let’s add  Label and Text Field to View by drag and drop them from Objects Library, then add :

#import <UIKit/UIKit.h>

@interface ButtonAndTextViewController : UIViewController {

   IBOutlet UITextField *textName;


@property (nonatomic,retain) UITextField *textName;

-(IBAction) btnClicked:(id) sender;

11. Open implementation file “ButtonAndTextViewController.m” and type following code after “@implementation ButtonAndTextViewController” :

@synthesize textName;

12. Change code for function “-(IBAction) btnClicked:(id) sender”

-(IBAction) btnClicked:(id) sender
NSString *str = [[NSString alloc] initWithFormat:@"Welcome Mr. %@ ", textName.text];
UIAlertView *alert = [[UIAlertView alloc]
    [alert show];
    [alert release];
    [str release];

13. While pressing Control-Key, Click on the “File’s Owner”  and drag to the UITextField, then select “textName”

14. Run the program, Try to type something in UITextField then click “OK” button to test. The output should like this :

Note :

  • “@property (nonatomic, retain) UITextField *textName;” means that you want the textName outlet to be expose as a property
  • IBAction Identifier is used to synchronize action methods
  • @synthesize keyword indicate that compiler will create getter and setter for the specific property.
  • The nonatomic keyword indicate that there is no need to ensure that the property is used in a thread-safe manner because it is not used in multiple threads.

I Also include the video how to do this in my facebook.

Categories: Iphone, Mac Os, Programming

Objective-C Basic knowledge

May 30, 2011 Leave a comment

This is small thing that i learned today while riding the train to buy some instant noodle in other town ^^.

From the Object Oriented Programming perspective, There is some difference between Objective-C and and other languages such as that derived from Simula, like C++, Java and C#. For non object operations, Objective-C are identical with C.

In objective-C, we don’t invoke a method, but instead send a message. Invoking a method implies that you know something about that method, while Sending message leaves it up to the message to figure out what to do with it.

This make Objective-C loosely coupled, that  make it much more dynamic at runtime than simula derived languages. In simula derived language you must know the type of an object before you can call the method. While in Objective-C, you simply send object with a message, then the receiving object try to interpret that message. In this case there is no guaranty of response, if Object doesn’t understand the message, it will return “nil”.

The other difference is in the way memory is managed. in Java there is Garbage Collection to handle memory management. Garbage collection frees the developer from manually managing the memory, but it routine consume additional computing resource.  Objective-C using “Reference counting”. This is a form of garbage collection, which count the number of reference to an object and frees the associate memory when the number of reference reach zero. The main advantages of reference counting over classic garbage collection is that memory is freed as soon as it no longer in use.

Almost Objective-C applications (Iphone Apps), uses Model-View-Controller (MVC) pattern. Rather than encouraging us to create subclass, MVC make use of delegate classes. MVC divide application into 3 functional pieces:

  • Model : Manage the application state and associate data. it’s entirely decoupled from the UI or presentation of application state to the user
  • View : is what user sees, and it displays the model for the user. It allow user to manipulate it and respond, and generate events
  • Controller : coordinates update of the view and the model when user interaction make changes to the model, and vice versa

Basic Objective-C Syntax :

Variable declaration look much same as other languages, method call are surrounded by square bracket.  For Example:

[anObject someMethod];  // The someMethod message is send to the anObject object.

[anObject someMethod : anotherObject]; // The someMethode message is sent to the anObject object and passes anotherObject as an argument

Categories: Iphone, Programming

Disable Code Signing in XCode 4

May 11, 2011 12 comments

Before you distribute Application on App Store, you may want to Test your application in Simulator or Iphone Device via XCode. This is no problem if you have enrolled IOS developer program and pay 99$/year,  generate a Certificate Signing Request and doing some other stuff. read this post.

But if you just want to test your Application on Iphone, and don’t intend to sell it in App Store, actually you don’t need to enrolled IOS developer program or pay 99$/year. Just just need to bypass the code signing. (Oops) it maybe only worked on Cydia-Installed Iphone.

So, first of all you have to Edit SDKSettings.plist. In this case I use XCode 4. you can find it in the /Developer/Platforms/iPhoneOS.platform/SDKs/iPhoneOS4.3.sdk/Developer. In the Default properties key change the CODE_SIGNING_REQUIRED parameter value form “YES” to “NO”, then Restart XCode if you running it.

And in your XCode project setting change the parameter value of  “Code Signing Identity” from “Iphone Developer” to “Don’t Code sign”

If you still have problem then open your browser,  and find the solution with google search engine. Good Luck 🙂

Categories: Iphone, Mac Os