检查应用程序是否已安装或首次安装的最佳方法是什么。
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
检查应用程序是否已安装或首次安装的最佳方法是什么。
捆绑版本并以用户默认值保存。
编辑:
这里有三件事需要注意。
捆绑版本:这是您想要发布的应用程序的版本。
旧版本:这将指示您的应用程序的以前版本。我们将把它存储在用户默认值中,以便在更新应用程序时知道旧版本是什么。如果您的捆绑包版本是1.0,那么这显然是零。
目标版本:这表示用户的目标版本。我们稍后将对此进行讨论。
因此,诸如
bundleVersion>;oldVersion
或
if(isVersionBetter:myBundleVersion thanVersion:oldVersion)
这意味着我们想要创建我们的数据库(在这种情况下,捆绑包版本为1.0,旧版本为nil),或者更新我们的数据库。
因此,正如我们所看到的,数据库的创建意味着用户是第一次安装应用程序。更新数据库意味着用户已经安装了应用程序并正在更新数据库。
但是,当你想更新你的应用程序并保持数据库的原样时,也可能会有这样的情况。也就是说,只有UI更新。
在这里,目标版本出现了。
如上所述,目标版本是用户的目标版本。如果用户的目标是捆绑包版本,所有这些都将和上面一样工作。但如果用户的目标是捆绑包版本之外的其他版本,我们将跳过数据库更新部分,从而只允许UI更改。
所以,最后的声明应该是这样的:
if( bundleVersion == targetVersion AND bundleVersion > oldVersion ) {
// Either create or update the database.
}else {
// Do nothing. Skips database updating and allows UI update.
}
因此,您的数据库函数将如下所示
-(void) initWithTargetVersion:(NSString *) targetVersion {
NSString *oldDatabaseVersion = [[NSUserDefaults standardUserDefaults] stringForKey:@"OldDatabaseVersion"];
NSString *bundleDatabaseVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
if([bundleDatabaseVersion isEqualToString:targetVersion] && [self isVersionBetter:oldDatabaseVersion new:targetVersion]) {
// Create or update the database.
}else {
// Do nothing.
}
}
其中用户将按如下方式传递目标版本:
[[DatabaseManager sharedManager] initWithTargetVersion:@"1.0"];
For a basic app with nonconsumable in-app purchases, has anyone figured out best practices for using SKPaymentQueue s restoreCompletedTransactions? Observations I know it s recommended to always ...
I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...
I have a UITextField that is a subview of a UITableViewCell. When my view loads, I want the text field to become first responder. I have a pointer to the text field in the table cell, so to do this I ...
I ve been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid ...
In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...
Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...
I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...
Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...