Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite 搜索栏不工作只是崩溃_Sqlite_Search - Fatal编程技术网

Sqlite 搜索栏不工作只是崩溃

Sqlite 搜索栏不工作只是崩溃,sqlite,search,Sqlite,Search,这是我数据库的代码 SQLiteTutorialAppDelegate.m $-(void)readAnimalsFromDatabase{ sqlite3 *database; animals = [[NSMutableArray alloc] init]; if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { const char *sqlStatement = "select * fro

这是我数据库的代码 SQLiteTutorialAppDelegate.m

$
-(void)readAnimalsFromDatabase{

sqlite3 *database;
animals = [[NSMutableArray alloc] init];
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {

    const char *sqlStatement = "select * from animals";
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
        while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
            // Read the data from the result row
            NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
            NSString *aDescription = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
            NSString *aImageUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];

            // Create a new animal object with the data from the database
            Animal *animal = [[Animal alloc] initWithName:aName description:aDescription url:aImageUrl];

            // Add the animal object to the animals Array
            [animals addObject:animal];

            [animal release];
        }
    }

    sqlite3_finalize(compiledStatement);

}
sqlite3_close(database);
}

这里是RootViewController.m

$
(无效)搜索栏:(UISearchBar*)搜索栏文本更改:(NSString*)搜索文本{

[copyListOfItems removeAllObjects];
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
SQLiteTutorialAppDelegate *appDelegate = (SQLiteTutorialAppDelegate *)[[UIApplication sharedApplication] delegate];
for(appDelegate.animals中的NSArray*行数组) { for(行数组中的NSString*aName)

}

请帮助我如何在TableView中创建搜索栏搜索数据库

这为您提供了一个示例,说明搜索栏如何使用周围的内容以及如何工作


我最近也做过类似的工作,这个网站应该告诉你所有的错误,并给你一个例子说明它是如何工作的

请总结你链接的内容。如果链接被破坏,我们希望答案对未来的访问者有用。
    {

        [searchArray addObject:rowArray]; // HERE CRASH 
    }
}


for (NSString *sTemp in searchArray)
{
    NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];

    if (titleResultsRange.length == 0)
        [copyListOfItems addObject:sTemp];
}

[self.tableView reloadData];