免费版限制应用程序(应用程序内购买)
问题描述:
我想将我的应用程序设置为免费版本,并在应用程序购买时将其解锁,以便获得更多曝光度。免费版本应该是有限的,这是我的问题。免费版限制应用程序(应用程序内购买)
我的应用程序大量使用核心数据并创建免费版本,我只是想将每个tableview中显示的所有记录限制为1行,或者如果有其他人有更好的想法,那些工作也是如此。
我一直在试图设置我的numberOfRowsInSection返回1,但每次我添加一些东西,我得到一个范围异常,因为我正在使用fetchedResultsController。有任何想法吗?
这是我的部分和行代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [[fetchedResultsController sections] count];}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];}
答
你可以在你的didSelectRow方法处理这个问题。如果该行不是0,则抛出一个UIAlertView,解释如何购买应用程序以使用完整版本。这也会向用户显示更多的内容存在。我似乎记得苹果不喜欢广告的完整版本,但我也看到了很多,所以我想现在好了。
答
在NSFetchRequest
上使用-setFetchLimit:
。如果你将它设置为1,那么NSFetchResultController将只给你一行。
答
我也做马库斯建议以上:
if(!appDelegate.fullVersion){
[fetchRequest setFetchLimit:10];
NSLog(@"only fetching 10 as not full version");
}
我检查的appDidFinishLaunching完整版,并保持在一个的appDelegate BOOL。
确保您添加setFetchLimit:在您希望使用的谓词之后。