0
I’m trying to filter the name of the cells in a table, loaded with data from Core Data, but I’m having a crash.
I am using the following code to filter the cell title:
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
if (searchText.length == 0) {
// Ajustando valor da flah booleana
isFiltrado = NO;
}else{
// Ajustando valor da flah booleana
isFiltrado = YES;
// Alloc e inicia nosso dadosFiltrados
dadosFiltrados = [[NSMutableArray alloc ]init];
//Fast enumeration
for (NSDictionary* nomeAtividade in arrayAtividadeLocal) {
NSRange rangeNomeAtividade = [[nomeAtividade objectForKey:@"atividade" ]rangeOfString:searchText];
if (rangeNomeAtividade.location != NSNotFound) {
[dadosFiltrados addObject: nomeAtividade];
}
}
}
I’m getting the following Xcode error:
Terminating app due to uncaught Exception 'Nsinvalidargumentexception', Reason: '-[Nsmanagedobject objectForKey:]: unrecognized selector sent to instance ...
i found the error but then came another logic: The 1st I decided by taking the titles of the objects coming from the core data and passing to a Nsmutablearray> However now, it even finds the object in the search but it always points to the first on the stack of the array :/
– Tiago Amaral
The funniest that it is now identical to the tutorial I made, and it works normally, but in the implementation of the project this with this problem of presenting the correct data in the search :/
– Tiago Amaral
You increased the process with this new iteration to have only the names. You can do everything in the same array. Finally, about the other problem, you need to know how the implementation was made.
– Paulo Rodrigues
Talk to me on Skype so I can show you better
– Tiago Amaral
I found the problem, was in cellForRowAtIndexPath, I was still feeding the cells with the original data, and not with the filtered data :D
– Tiago Amaral
Oh yes, by the method you’re using, I didn’t imagine you were using the
UISearchDisplay
. For it yes, you have a table with different data only with the search result.– Paulo Rodrigues
Do you know anything about APNS? I just need to create a push notification system and my app will be finished... but I don’t want to use any third party service, I already own a web service... I posted the question in stackoverflow, but if you want we can chat by skype, if you can tbm
– Tiago Amaral