搜索栏与ios中的表视图

时间:2013-12-03 06:14:23

标签: ios5 nspredicate

我在NSPredicate

中收到错误
"*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "title tcontains[cd] %@"'
*** First throw call stack:
(0x15d6012 0x13fbe7e 0xe14355 0xe14173 0xe14127 0x5b68 0x5deb 0x626ff3 0x576c86 0x140f705 0x343213 0x404c7e 0x404310 0x41113c 0x41b5a6 0xebc4f9 0x16300c5 0x158aefa 0xdf0bb2 0x406e9de 0x31bc1da 0x35f5dfc 0x35f8bf8 0x4049612 0x404974a 0x4049ec0 0x4049cb8 0x4049204 0x343722b 0x3437193 0x401be96 0x40484cc 0x35f3136 0x35f23c6 0x3625980 0x3c817fd 0x361c576 0x361d6da 0x361b72e 0x3c7feaa 0x3635af1 0x362572a 0x35f96ae 0x31f862b 0x140f6b0 0x4064810 0x32371a4 0x32392ff 0x5010b4 0x4c3aef 0x4c4e58 0x4c39fe 0x4cdd29 0x350ddb 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x44e7f5 0x350e35 0x350806 0x350beb 0x342698 0x22fcdf9 0x22fcad0 0x154bbf5 0x154b962 0x157cbb6 0x157bf44 0x157be1b 0x22fb7e3 0x22fb668 0x33fffc 0x201d 0x1f45)
libc++abi.dylib: terminate called throwing an exception"

请帮帮我。

这是我的代码

- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{

    [searchResults removeAllObjects];

    NSString *str1 = [searchText stringByReplacingOccurrencesOfString:@"\"" withString:@""];
    NSLog(@"data_arra==>%@",arr_search);
    NSLog(@"searchText==>%@",searchText);

    NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"title tcontains[cd] %@",
                                    str1];
    NSLog(@"result==>%@",resultPredicate);

    searchResults = [NSMutableArray arrayWithArray:[arr_search filteredArrayUsingPredicate:resultPredicate]];
}


array value for arr_search 

arr_search ==>(
    "Phoenix Market City",
    "Express Avenue",
    "Ampa Skywalk",
    "The Forum Vijaya Mall",
    "Chennai Citi Centre",
    "Spencer Plaza",
    "Chandra Metro Mall",
    "The Grand Mall",
    "Ramee Mall",
    "Alsa Mall",
    "Prince Plaza",
    "Ispahani Centre",
    "Fountain Plaza",
    Lifestyle,
    "Grand Venus Spectrum Mall",
    "Raahat Palaza",
    "Patni Plaza",
    "Maya Plaza",
    "Phoenix Mall, Chennai",
    Megamart,
    "Phoenix marketcity",
    Aldo,
    "Gokul Arcade",
    "Parsn Complex",
    "Spectrum mall",
    "Express Avenue Chambers",
    "Big Bazaar",
    "Spencer's",
    "Saravana Stores",
    "CEX (complete entertainment exchange)"
)

1 个答案:

答案 0 :(得分:1)

我认为这是

中的拼写错误
NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"title tcontains[cd] %@",
                                    str1];

应该是

NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"title contains[cd] %@",
                                    str1];