내 add_clicked 무효입니다 : 내 예약 클래스 내부
- (void) add_Clicked:(id)sender {
NSURL *url = [[NSURL alloc] initWithString:@"http://sites.google.com/site/iphonesdktutorials/xml/Books.xml"];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//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!!!");
[self.tableView reloadData];
}
내가 getInitialDataToDisplay이라는 빈 공간이있다. 이것이 내가 약간의 변경을해야만하는 곳이라고 생각하거나,이 메소드를 다시 호출 할 수 있습니까? 문제는 응용 프로그램이로드 될 때 tableView 경우에만 sqlite 콘텐츠를 읽는 것입니다. 그리고 예, 저는 프로그래밍에 대한 경험이 전혀 없지만 조금 배웠습니다.
+ (void) getInitialDataToDisplay:(NSString *)dbPath {
BooksAppDelegate *appDelegate = (BooksAppDelegate *)[[UIApplication sharedApplication] delegate];
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
const char *sql = "select bookID, title from books";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0);
Book *bookObj = [[Book alloc] initWithPrimaryKey:primaryKey];
bookObj.title = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
bookObj.isDirty = NO;
[appDelegate.bookArray addObject:bookObj];
[bookObj release];
}
}
}
else
sqlite3_close(database); //Even though the open call failed, close the database connection to release all the memory.
}
코드를 붙여 넣을 수 있습니까? 문제는 tableView 데이터를 다시로드하는 것이 아니라 내용을 읽는 것입니다. SQLite 데이터베이스에서 내용을 읽으 실 건가요? 그리고 XML을 파싱 한 후이 작업을 수행하고 있습니까? – Trinca