Okay, I've finally figured out how to get a UISearchBar into my iPhone app (a
custom phone book for my company's internal use). Here's what I have
Model:
NSMutableArray (read from a .plist file in the bundle, then written out (1st
time) to application's documents directory. Represents the list of all stores.)
NSMutableDictionary instances (each holds the same keys, but with different
values for the keys, all of which are either NSString or NSNumber - the keys
are, of course, NSStrings. Each NSDictionary represents the info for a single
store.)
why? Because these classes can read/write directly to/from plists. :)
View hierarchy:
UIWindow
UIView
UINavigationBar
UITableView - This is where the StoreDetailView and
AddEditDetailView return to when popped off
UISearchBar the navController.
StoreDetailView \_ one of these will be pushed onto the navController
when the user selects
AddEditDetailView / a row from the UITableView
(I may have missed one here...)
Everything worked before adding the UISearchBar. I added the UISearchBar based
on info I read from one of those 'learn CocoaTouch for iOS' books... That shows
up (and I've got the appropriate changes in the headers to tell my view
controller that it implements UISearchBarDelegate), and implemented a stub
method searchBar:textDidChange: but I don't think this is going to help. How do
I turn this into an NSPredicate so I can search the model? Basically, I want
something like:
this should be an NSDictionary
|
v
If (array[indexPath row] valueForKey:kCompanyCode = <search text>) or
(array[indexPath row] valueForKey = kStoreNum) Or (...) then
// Use the NSPredicate to narrow the selection of rows the model will 'show'
the view controller
else
// do nothing - no matching fields for search text
end if
Am I going to have to use CoreData to get NSPredicates to work here, or can I
coerce an NSMutableArray to work if I implement some interface for searching
with NSPredicates?
At this point, I'm totally confused about how NSPredicates do their work.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]