2010年4月8日木曜日

Load XML from local

NSString *path = [[NSBundle mainBundle] pathForResource:@"Books" ofType:@"xml"];

NSData *xmlData = [NSData dataWithContentsOfFile:path];

NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];

//Initialize the delegate.

XMLParser *parser = [[XMLParser alloc] initXMLParser];

//Set delegate

[xmlParser setDelegate:parser];

//Start parsing the XML file.

BOOL success = [xmlParser parse];

if(success)

NSLog(@"No Errors");

else

NSLog(@"Error Error Error!!!");

2010年3月22日月曜日

SQLite3 Experiment

- (void)loadNamesFromDatabase

{

NSString *file = [[NSBundle mainBundle] pathForResource:@"records" ofType:@"db"];

sqlite3 *database = NULL;

if (sqlite3_open([file UTF8String], &database) == SQLITE_OK) {

sqlite3_exec(database, "SELECT game FROM records", MyCallback, records, NULL);

}

sqlite3_close(database);

}


- (IBAction)addNewRecord:(id)sender{

NSLog(@"addnew");

[self insertNew];

}


-(void)insertNew{

NSString *file = [[NSBundle mainBundle] pathForResource:@"records" ofType:@"db"];

sqlite3 *database = NULL;

if (sqlite3_open([file UTF8String], &database) == SQLITE_OK) {

sqlite3_exec(database, "insert into records (game, number, time) values (0,1,50)", MyCallback, records, NULL);

}

sqlite3_close(database);

}


2010年3月17日水曜日

About The iPhone


iPhone is a good and unique platform to build an application. However just like other platform, to develop a great application we need to learn it constantly. I hope I can follow an advise from Japanese developer to learn iPhone SDK at least 3 hours a day.