开发者

issue modally presenting a table view controller that has a search display controller and returning the selected cell

开发者 https://www.devze.com 2023-03-07 00:47 出处:网络
in my iOS application, i\'m wanting to present the user a table of items using a UITableViewController, have them select an item, then return that item back to the another view controller. i can do th

in my iOS application, i'm wanting to present the user a table of items using a UITableViewController, have them select an item, then return that item back to the another view controller. i can do this successfully by defining a protocol and delegate method for the table view controller, presenting the table view controller modally, then dismissing it when the user selects an item开发者_运维技巧 and returning the item to the delegate view controller. but, if i also implement a search display controller for the table view (so the user can search for a specific item in a longer list) i run into a memory issue. i've modified apple's 'TableSearch' example to demonstrate this, and have posted the code at https://github.com/pistachionut/Table-Search-Example

in short, the app usually crashes with an EXC_BAD_ACCESS just after selecting a cell in the table view. running it with NSZombieEnabled is indicating that the table view controller is being called by -[UISearchDisplayController _destroyManagedTableView] after its retain count has reached 0. anyone have an idea why this is happening? i don't think i'm doing any additional releasing of the table view controller beyond what i'm responsible for. i create it using alloc and initWithNibName, present it modally, then imediately release it (see -(IBAction)showProductPicker:(id)sender in the 'PickProductViewController.m' file in my example). thanks!


the answer posted by Jeff to How can UISearchDisplayController autorelease cause crash in a different view controller? solves the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消