Skip to content

Instantly share code, notes, and snippets.

@annidy
Created December 16, 2014 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annidy/0d7b462fe90b42a24446 to your computer and use it in GitHub Desktop.
Save annidy/0d7b462fe90b42a24446 to your computer and use it in GitHub Desktop.
FMDB userver 扩展
#import "FMDatabase.h"
@interface FMDatabase (UserVer)
@property (nonatomic) int userVer;
@end
#import "FMDatabase+UserVer.h"
@implementation FMDatabase (UserVer)
- (int)userVer
{
FMResultSet *rs = [self executeQuery:@"PRAGMA user_version;"];
if ([rs next]) {
return [rs intForColumnIndex:0];
}
return 0;
}
- (void)setUserVer:(int)userVer
{
NSString *sql = [NSString stringWithFormat:@"PRAGMA user_version = %d;", userVer];
BOOL succes = [self executeUpdate:sql];
NSAssert(succes, @"Set Uer Ver");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment