0
나는 SearchDisplayController
NSInvalidArgumentException이 - 알 수없는 선택 예를
- (void)handleSearchForTerm:(NSString *)searchTerm{
[self.searchResults removeAllObjects]; // First clear the filtered array.
FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
FMResultSet *results = [db executeQuery: [NSString stringWithFormat:@"SELECT * FROM periods where (searchstartyear <= %@) AND (searchendyear >= %@)", searchTerm, searchTerm]];
NSMutableArray *array = [[NSMutableArray alloc] init ];
[array removeAllObjects];
while ([results next]) {
Periods *searchPeriod = [[Periods alloc] init];
searchPeriod.periodname = [results stringForColumn:@"PeriodName"];
searchPeriod.startyear = [results stringForColumn:@"StartYear"];
searchPeriod.endyear = [results stringForColumn:@"EndYear"];
searchPeriod.thumb = [results stringForColumn:@"Thumb"];
searchPeriod.childid = [results stringForColumn:@"ChildID"];
[array addObject:searchPeriod];
}
[self.searchResults addObject:array];
[db close];}
기간을 사용하여 검색을 수행하는 객체 나는 NSInvalidArgumentException을 얻을
#import <UIKit/UIKit.h>
@interface Periods : NSObject
@property (nonatomic,strong) NSString *periodname;
@property (nonatomic,strong) NSString *startyear;
@property (nonatomic,strong) NSString *endyear;
@property (nonatomic,strong) NSString *thumb;
@property (nonatomic,strong) NSString *childid;
@end
을 다음과 같은 기능을한다 사용하고
로 전송 - 알 수없는 선택 다음 코드가 실행될 때 인스턴스로 전송됩니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PeriodsCell";
UITableViewCell *cell = [self.mainTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
if (tableView != [[self searchDisplayController] searchResultsTableView])
{
NSMutableArray *array = [periodsdataarray objectAtIndex:indexPath.section];
NSMutableDictionary *dictionary = [array objectAtIndex:indexPath.row];
UILabel *childIDLabel = (UILabel *)[cell viewWithTag:999];
childIDLabel.text = [dictionary valueForKey:@"ChildID"];
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
titleLabel.text = [dictionary valueForKey:@"PeriodName"];
UILabel *previewLabel = (UILabel *)[cell viewWithTag:101];
previewLabel.text = [NSString stringWithFormat:@"%@ - %@",[dictionary valueForKey:@"StartYear"],[dictionary valueForKey:@"EndYear"]];
UIImageView *imageview = (UIImageView *)[cell viewWithTag:102];
[imageview setImage:[UIImage imageNamed:[dictionary valueForKey:@"Thumb"]]];
}
else
{
Periods *periodcell = [self.searchResults objectAtIndex:indexPath.row];
cell.tag = 666;
UILabel *childIDLabel = (UILabel *)[cell viewWithTag:999];
childIDLabel.text = periodcell.childid;
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
titleLabel.text = periodcell.periodname;
UILabel *previewLabel = (UILabel *)[cell viewWithTag:101];
previewLabel.text = [NSString stringWithFormat:@"%@ - %@",periodcell.startyear,periodcell.endyear];
UIImageView *imageview = (UIImageView *)[cell viewWithTag:102];
[imageview setImage:[UIImage imageNamed:periodcell.thumb]];
}
return cell;
}
,
... 그리고 더 구체적으로이 행이 실행될 때 : 내가 잘못 뭐하는 거지
childIDLabel.text = periodcell.childid;
?
선택자가 전송되는 인스턴스의 클래스는 무엇입니까? –
죄송 합니다만 귀하의 질문을 이해할 수 있는지 확실하지 않습니다. –
예외가 있다고 말씀하셨습니다. 보통 예외는 클래스 이름을 언급합니다. –