views:

64

answers:

1

Please help because I think I'm going mad.

I have a core data collection that contains many thousand records. Some of the fields in these records contain terms that have a single quote. When building the database from XML, we created two fields - a NAME field and a SORTFIELD field.

The NAME field contains the full term and is used for display purposes in our application.

The SORTFIELD field contains the same content as the NAME field but is converted to lowercase and has all single quote characters removed using the following.

[NSString stringByReplacingOccurrencesOfString:@"'" withString:@""]; 

When the user enters the string for which they wish to search, we remove single quotes from the search string entered and convert to lowercase using the same method as when creating the data. However it does not find any results.

If the user enters Michael's, the system fails to find any records

The predicate is "SORTFIELD like 'michaels'"

If the user enters Michael' (single quote no 's' character), the system finds all records starting Michael's

The predicate is "SORTFIELD like 'michael'"

I am sure we are doing something very stupid and appreciate any pointers on how to resolve this issue as we have gone round and round in circles.

We have placed many NSLog entries to track actual content of the search fields and record fields and all display as expected.

Thanks Mike

A: 

I finally resolved the issue on finding that the fields being searched had a non-displayable character when a single quote existed. For example Michael's displayed but Michaelx's where x= an extended ascii character, was the actual contents.

By removing this from the fields we were able to perform the searching as described in our original posting.

However, I still feel that you should be able to search a Core Data collection for strings that contain single quotes without having to do the 'hack' described.

Welcome any thoughts from others on this.

Thanks Mike

Mike Williams