tags:

views:

64

answers:

3

Hi,

I recently submitted an app for app review but I got rejected because of the use of a private API. I'm still a bit new to iPhone developing so I was wondering if someone could help me understand how this part was rejected:

UISearchBar *searchBar = [[[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 0)] autorelease];
searchBar.showsCancelButton = NO;
searchBar.placeholder = @"Search Exhibitors";
[searchBar sizeToFit];

[self.tableView setTableHeaderView:searchBar];

UISearchDisplayController *searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];  

[self performSelector:@selector(setSearchDisplayController:) withObject:searchDisplayController];

[searchDisplayController setDelegate:self];  
[searchDisplayController setSearchResultsDataSource:self];  
[searchDisplayController setSearchResultsDelegate:self];
[searchDisplayController release];

The part that they mentioned was the "setSearchDisplayController". I based the searching of a UITableView on the example given here. So can anyone explain why this is considered a private API?

+1  A: 

Is -setSearchDisplayController: mentioned anywhere in the documentation (I don't think it is)? If it is not then it's not a public API.

The fact that you have to use -performSelector:withObject: and can't call it directly is another giveaway. -setSearchDisplayController obviously isn't included in any header files.

Thomas Müller
A: 

I got bit by this recently too.

searchDisplayController is a readonly property of UIViewController.

Create an ivar (and name it something other than searchDisplayController). Don't forget to delete the [release]; line and move it to - (void)dealloc.

Rafif Yalda
A: 

I just got the same rejection reason back from Apple. Therefore I'm happy to have the solution for this ridiculous issue.

I think it would be a good idea to inform the blog owner of the incorrect code sample to avoid further misunderstandings.

Joe