├── README.md
├── URLNavigation
├── en.lproj
│ └── InfoPlist.strings
├── CViewController.h
├── DViewController.h
├── EViewController.h
├── YQNavigationViewController.h
├── BViewController.h
├── AppDelegate.h
├── ViewControllers.h
├── AViewController.h
├── main.m
├── URLNavigation-Prefix.pch
├── Images.xcassets
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── LaunchImage.launchimage
│ │ └── Contents.json
├── YQCacheCenter.h
├── YQNavigator.h
├── YQDBCenter.h
├── YQBaseViewController.h
├── YQDefine.h
├── Sample.h
├── YQCacheCenter.m
├── YQNavigationViewController.m
├── URLNavigation-Info.plist
├── EViewController.m
├── YQBaseViewController.m
├── YQDBCenter.m
├── DViewController.m
├── CViewController.m
├── BViewController.m
├── YQNavigator.m
├── AppDelegate.m
├── AViewController.m
└── Sample.m
├── URLNavigationTests
├── en.lproj
│ └── InfoPlist.strings
├── URLNavigationTests-Info.plist
└── URLNavigationTests.m
├── Vendor
└── FMDB-v2.3
│ ├── fmdb
│ ├── FMDB.h
│ ├── FMDatabasePool.h
│ ├── FMDatabaseQueue.h
│ ├── FMDatabaseQueue.m
│ ├── FMDatabaseAdditions.m
│ ├── FMDatabaseAdditions.h
│ ├── FMDatabasePool.m
│ ├── FMResultSet.m
│ ├── FMResultSet.h
│ └── FMDatabase.h
│ └── extra
│ ├── FMDatabase+InMemoryOnDiskIO.h
│ └── FMDatabase+InMemoryOnDiskIO.m
├── URLNavigation.xcodeproj
├── xcuserdata
│ └── jasper.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── URLNavigation.xcscheme
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcuserdata
│ │ └── jasper.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcshareddata
│ │ └── URLNavigation.xccheckout
└── project.pbxproj
├── .gitignore
└── Extension
├── NSString+YQ.h
└── NSString+YQ.m
/README.md:
--------------------------------------------------------------------------------
1 | URLNavigation
2 | =============
3 |
4 | URLNavigationDemo
5 |
--------------------------------------------------------------------------------
/URLNavigation/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/URLNavigationTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDB.h:
--------------------------------------------------------------------------------
1 | #import "FMDatabase.h"
2 | #import "FMResultSet.h"
3 | #import "FMDatabaseAdditions.h"
4 | #import "FMDatabaseQueue.h"
5 | #import "FMDatabasePool.h"
6 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/xcuserdata/jasper.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/project.xcworkspace/xcuserdata/jasper.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JasperYanky/URLNavigation/HEAD/URLNavigation.xcodeproj/project.xcworkspace/xcuserdata/jasper.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # CocoaPods
2 | #
3 | # We recommend against adding the Pods directory to your .gitignore. However
4 | # you should judge for yourself, the pros and cons are mentioned at:
5 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control?
6 | #
7 | # Pods/
8 |
9 |
--------------------------------------------------------------------------------
/URLNavigation/CViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // CViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @interface CViewController : YQBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/URLNavigation/DViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // DViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @interface DViewController : YQBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/URLNavigation/EViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // EViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @interface EViewController : YQBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/URLNavigation/YQNavigationViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQNavigationViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface YQNavigationViewController : UINavigationController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/URLNavigation/BViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // BViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @interface BViewController : YQBaseViewController
12 | - (void)loadMessageID:(NSNumber *)messageID;
13 | @end
14 |
--------------------------------------------------------------------------------
/URLNavigation/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/URLNavigation/ViewControllers.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewControllers.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 |
10 | #import "AViewController.h"
11 | #import "BViewController.h"
12 | #import "CViewController.h"
13 | #import "DViewController.h"
14 | #import "EViewController.h"
--------------------------------------------------------------------------------
/URLNavigation/AViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // AViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @class Sample ;
12 |
13 |
14 | @interface AViewController : YQBaseViewController
15 | {
16 |
17 | }
18 | @property (nonatomic,strong) Sample *sample;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/URLNavigation/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "AppDelegate.h"
12 |
13 | int main(int argc, char * argv[])
14 | {
15 | @autoreleasepool {
16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/URLNavigation/URLNavigation-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header
3 | //
4 | // The contents of this file are implicitly included at the beginning of every source file.
5 | //
6 |
7 | #import
8 |
9 | #ifndef __IPHONE_5_0
10 | #warning "This project uses features only available in iOS SDK 5.0 and later."
11 | #endif
12 |
13 | #ifdef __OBJC__
14 | #import
15 | #import
16 | #endif
17 |
--------------------------------------------------------------------------------
/URLNavigation/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "40x40",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "60x60",
16 | "scale" : "2x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/URLNavigation/YQCacheCenter.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQCacheCenter.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | @interface YQCacheCenter : NSObject
13 | @property (nonatomic,strong) NSCache *mainCache;
14 | @property (nonatomic,strong) NSCache *imageCache;
15 |
16 | + (YQCacheCenter *)shareCacheCenter;
17 | //这个缓存是最简单的缓存,如果要更高级的,可以考虑归档等功能制作缓存
18 | @end
19 |
--------------------------------------------------------------------------------
/URLNavigation/YQNavigator.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQNavigator.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class YQNavigationViewController;
12 | @class YQBaseViewController;
13 |
14 | //主要的解析器
15 | @interface YQNavigator : NSObject
16 | + (void)showViewControllerToURL:(NSString*)aURL
17 | from:(YQBaseViewController*)aViewController;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/URLNavigation/YQDBCenter.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQDBCenter.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "FMDB.h"
11 |
12 | @interface YQDBCenter : NSObject
13 | @property (nonatomic,strong) FMDatabaseQueue *dbQueue;
14 | + (YQDBCenter *)shareDatabase;
15 |
16 | //获取一个异步的数据库队列
17 | + (FMDatabaseQueue *)dbQueue;
18 |
19 | //获取一个同步的数据库
20 | + (FMDatabase *)syncDB;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/URLNavigation/YQBaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQBaseViewController.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "YQNavigationViewController.h"
11 | #import "YQDefine.h"
12 | #import "NSString+YQ.h"
13 | #import "YQNavigator.h"
14 |
15 | @interface YQBaseViewController : UIViewController
16 | @property (nonatomic, strong) YQNavigationViewController *yqNavigationController;
17 |
18 |
19 | - (void)back;
20 | @end
21 |
--------------------------------------------------------------------------------
/URLNavigation/YQDefine.h:
--------------------------------------------------------------------------------
1 | //
2 | // YQDefine.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 |
10 |
11 | //协议的头部
12 | #define YQPROTOCOL @"app"
13 | #define HTTP @"http"
14 |
15 | #define AVC @"avc"
16 | #define AVC_URL @"app://avc"
17 |
18 | #define BVC @"bvc"
19 | #define BVC_URL @"app://bvc"
20 |
21 | #define CVC @"cvc"
22 | #define CVC_URL @"app://cvc"
23 |
24 | #define DVC @"dvc"
25 | #define DVC_URL @"app://dvc"
26 |
27 | #define EVC @"evc"
28 | #define EVC_URL @"app://evc"
29 |
30 |
--------------------------------------------------------------------------------
/URLNavigation/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "iphone",
6 | "extent" : "full-screen",
7 | "minimum-system-version" : "7.0",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "portrait",
12 | "idiom" : "iphone",
13 | "subtype" : "retina4",
14 | "extent" : "full-screen",
15 | "minimum-system-version" : "7.0",
16 | "scale" : "2x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
--------------------------------------------------------------------------------
/URLNavigation/Sample.h:
--------------------------------------------------------------------------------
1 | //
2 | // Sample.h
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Sample : NSObject
12 | @property (nonatomic,strong) NSNumber *messageID;
13 | @property (nonatomic,strong) NSString *messageContent;
14 |
15 | //同步存储
16 | - (void)syncSave;
17 |
18 | //异步存储
19 | - (void)asyncSave;
20 |
21 | //同步获取
22 | + (Sample *)syncFetchBy:(NSNumber *)messageID;
23 |
24 | //异步获取
25 | + (void)asyncFetchBy:(NSNumber *)messageID doneBlock:(void (^)(Sample *))doneBlock;
26 |
27 | //创建数据的sql语句
28 | + (NSString *)creatSampleStructureforDB;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/xcuserdata/jasper.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | URLNavigation.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | A4C0E777197CB2FD005DDFD0
16 |
17 | primary
18 |
19 |
20 | A4C0E798197CB2FE005DDFD0
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/URLNavigation/YQCacheCenter.m:
--------------------------------------------------------------------------------
1 | //
2 | // YQCacheCenter.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQCacheCenter.h"
10 |
11 | @implementation YQCacheCenter
12 |
13 | +(YQCacheCenter *)shareCacheCenter{
14 | static YQCacheCenter *shareCacheCenter = nil;
15 | static dispatch_once_t onceToken;
16 | dispatch_once(&onceToken, ^{
17 | shareCacheCenter = [[YQCacheCenter alloc] init];
18 | });
19 | return shareCacheCenter;
20 | }
21 |
22 |
23 |
24 | - (id)init
25 | {
26 | self = [super init];
27 | if (self) {
28 | _mainCache = [[NSCache alloc]init];
29 | _imageCache = [[NSCache alloc]init];
30 | }
31 | return self;
32 | }
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/URLNavigationTests/URLNavigationTests-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.jasper.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/URLNavigationTests/URLNavigationTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // URLNavigationTests.m
3 | // URLNavigationTests
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface URLNavigationTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation URLNavigationTests
16 |
17 | - (void)setUp
18 | {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown
24 | {
25 | // Put teardown code here. This method is called after the invocation of each test method in the class.
26 | [super tearDown];
27 | }
28 |
29 | - (void)testExample
30 | {
31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Extension/NSString+YQ.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+PX.h
3 | // Paixin
4 | //
5 | // Created by Jasper on 14-3-4.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | /*
12 | 解析 协议的 Category
13 | 该类是Three20架构的一部分,用于解析URLManger 中具体协议命令
14 | */
15 |
16 | /**
17 | * @param NSString *URL 需要解析的URL,格式如:http://host.name/testpage/?keyA=valueA&keyB=valueB
18 | * @return NSDictionary *params 从URL中解析出的参数表
19 | * PROTOCOL 如 http
20 | * HOST 如 host.name
21 | * PARAMS 如 {keyA:valueA, keyB:valueB}
22 | * URI 如 /testpage
23 | */
24 |
25 | #define PROTOCOL @"PROTOCOL" //协议类型
26 | #define HOST @"HOST" //地址
27 | #define PARAMS @"PARAMS" //参数
28 | #define PATH @"PATH" //路径
29 |
30 |
31 | @interface NSString (YQ)
32 |
33 |
34 | - (NSDictionary *)paramsFromURL;
35 | - (NSString *)addUrlFromDictionary:(NSDictionary*)params;
36 | - (NSString *)urlencode;
37 | - (NSString *)urldecode;
38 | - (NSString *)MD5;
39 |
40 | - (NSString *)substringFromIndex:(NSUInteger )fromIndex toIndex:(NSUInteger)toIndex;
41 |
42 |
43 |
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/extra/FMDatabase+InMemoryOnDiskIO.h:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabase+InMemoryOnDiskIO.h
3 | // FMDB
4 | //
5 | // Created by Peter Carr on 6/12/12.
6 | //
7 | // I find there is a massive performance hit using an "on-disk" representation when
8 | // constantly reading from or writing to the DB. If your machine has sufficient memory, you
9 | // should get a significant performance boost using an "in-memory" representation. The FMDB
10 | // warpper does not contain methods to load an "on-disk" representation into memory and
11 | // similarly save an "in-memory" representation to disk. However, SQLite3 has built-in
12 | // support for this functionality via its "Backup" API. Here, we extend the FMBD wrapper
13 | // to include this functionality.
14 | //
15 | // http://www.sqlite.org/backup.html
16 |
17 | #import "FMDatabase.h"
18 |
19 | @interface FMDatabase (InMemoryOnDiskIO)
20 |
21 | // Loads an on-disk representation into memory.
22 | - (BOOL)readFromFile:(NSString*)filePath;
23 |
24 | // Saves an in-memory representation to disk
25 | - (BOOL)writeToFile:(NSString *)filePath;
26 | @end
27 |
--------------------------------------------------------------------------------
/URLNavigation/YQNavigationViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // YQNavigationViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQNavigationViewController.h"
10 |
11 | @interface YQNavigationViewController ()
12 |
13 | @end
14 |
15 | @implementation YQNavigationViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 | }
31 |
32 | - (void)didReceiveMemoryWarning
33 | {
34 | [super didReceiveMemoryWarning];
35 | // Dispose of any resources that can be recreated.
36 | }
37 |
38 | /*
39 | #pragma mark - Navigation
40 |
41 | // In a storyboard-based application, you will often want to do a little preparation before navigation
42 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
43 | {
44 | // Get the new view controller using [segue destinationViewController].
45 | // Pass the selected object to the new view controller.
46 | }
47 | */
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/URLNavigation/URLNavigation-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIdentifier
12 | com.jasper.${PRODUCT_NAME:rfc1034identifier}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/URLNavigation/EViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // EViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "EViewController.h"
10 |
11 | @interface EViewController ()
12 |
13 | @end
14 |
15 | @implementation EViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 |
31 | UILabel *label = [[UILabel alloc]init];
32 | label.text = @"D";
33 | label.textAlignment = NSTextAlignmentCenter;
34 | label.frame = CGRectMake(0, 250, 320, 50);
35 | [self.view addSubview:label];
36 |
37 | }
38 |
39 | - (void)didReceiveMemoryWarning
40 | {
41 | [super didReceiveMemoryWarning];
42 | // Dispose of any resources that can be recreated.
43 | }
44 |
45 | /*
46 | #pragma mark - Navigation
47 |
48 | // In a storyboard-based application, you will often want to do a little preparation before navigation
49 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
50 | {
51 | // Get the new view controller using [segue destinationViewController].
52 | // Pass the selected object to the new view controller.
53 | }
54 | */
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/URLNavigation/YQBaseViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // YQBaseViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQBaseViewController.h"
10 |
11 | @interface YQBaseViewController ()
12 |
13 | @end
14 |
15 | @implementation YQBaseViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 |
31 | self.view.backgroundColor = [UIColor whiteColor];
32 | }
33 |
34 | - (void)didReceiveMemoryWarning
35 | {
36 | [super didReceiveMemoryWarning];
37 | // Dispose of any resources that can be recreated.
38 | }
39 |
40 |
41 |
42 | - (void)back
43 | {
44 |
45 | if (self.yqNavigationController) {
46 | [self.yqNavigationController popViewControllerAnimated:YES];
47 | }
48 |
49 |
50 | }
51 |
52 | /*
53 | #pragma mark - Navigation
54 |
55 | // In a storyboard-based application, you will often want to do a little preparation before navigation
56 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
57 | {
58 | // Get the new view controller using [segue destinationViewController].
59 | // Pass the selected object to the new view controller.
60 | }
61 | */
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/project.xcworkspace/xcshareddata/URLNavigation.xccheckout:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDESourceControlProjectFavoriteDictionaryKey
6 |
7 | IDESourceControlProjectIdentifier
8 | 5A60C046-F9A1-43D7-8DCA-EDAEAE9E7A59
9 | IDESourceControlProjectName
10 | URLNavigation
11 | IDESourceControlProjectOriginsDictionary
12 |
13 | 2C1C2ED7-1546-4D13-AB57-53ED885CCF73
14 | https://github.com/JasperYanky/URLNavigation.git
15 |
16 | IDESourceControlProjectPath
17 | URLNavigation.xcodeproj/project.xcworkspace
18 | IDESourceControlProjectRelativeInstallPathDictionary
19 |
20 | 2C1C2ED7-1546-4D13-AB57-53ED885CCF73
21 | ../..
22 |
23 | IDESourceControlProjectURL
24 | https://github.com/JasperYanky/URLNavigation.git
25 | IDESourceControlProjectVersion
26 | 110
27 | IDESourceControlProjectWCCIdentifier
28 | 2C1C2ED7-1546-4D13-AB57-53ED885CCF73
29 | IDESourceControlProjectWCConfigurations
30 |
31 |
32 | IDESourceControlRepositoryExtensionIdentifierKey
33 | public.vcs.git
34 | IDESourceControlWCCIdentifierKey
35 | 2C1C2ED7-1546-4D13-AB57-53ED885CCF73
36 | IDESourceControlWCCName
37 | URLNavigation
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/URLNavigation/YQDBCenter.m:
--------------------------------------------------------------------------------
1 | //
2 | // YQDBCenter.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQDBCenter.h"
10 | #import "Sample.h"
11 |
12 | #define kDBName @"yq.sqlite3"
13 |
14 | @implementation YQDBCenter
15 |
16 | +(YQDBCenter *)shareDatabase{
17 | static YQDBCenter *shareDatabase = nil;
18 | static dispatch_once_t onceToken;
19 | dispatch_once(&onceToken, ^{
20 | shareDatabase = [[YQDBCenter alloc] init];
21 | });
22 | return shareDatabase;
23 | }
24 |
25 | +(FMDatabaseQueue *)dbQueue
26 | {
27 | return [YQDBCenter shareDatabase].dbQueue;
28 | }
29 |
30 | +(FMDatabase *)syncDB
31 | {
32 | return [[FMDatabase alloc]initWithPath:[YQDBCenter databasePath]];
33 | }
34 |
35 |
36 | #pragma mark -
37 |
38 | - (id)init
39 | {
40 | self = [super init];
41 | if (self) {
42 | _dbQueue = [FMDatabaseQueue databaseQueueWithPath:[YQDBCenter databasePath]];
43 | [YQDBCenter creatDatabase];
44 | }
45 | return self;
46 | }
47 |
48 | #pragma mark - database base operation
49 | + (NSString *)databasePath
50 | {
51 | NSString *applicationSupportPath = [NSHomeDirectory() stringByAppendingString:@"/Documents/DB"];
52 | if (![[NSFileManager defaultManager]fileExistsAtPath:applicationSupportPath]) {
53 | [[NSFileManager defaultManager] createDirectoryAtPath:applicationSupportPath withIntermediateDirectories:YES attributes:nil error:nil];
54 | }
55 | return [applicationSupportPath stringByAppendingString:[NSString stringWithFormat:@"/%@",kDBName]];
56 | }
57 |
58 | + (void)creatDatabase
59 | {
60 | //创建好友数据库 以及 信息数据库
61 | FMDatabase *db = [YQDBCenter syncDB];
62 | [db open];
63 | BOOL isWork = [db executeUpdate:[Sample creatSampleStructureforDB]];
64 |
65 | if (isWork) {
66 | NSLog(@"creatDatabase success ~");
67 | }else{
68 | NSLog(@"creatDatabase fail ~");
69 | }
70 |
71 | [db close];
72 | }
73 |
74 |
75 |
76 |
77 |
78 | @end
79 |
--------------------------------------------------------------------------------
/URLNavigation/DViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // DViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "DViewController.h"
10 |
11 | @interface DViewController ()
12 |
13 | @end
14 |
15 | @implementation DViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 |
31 | UIButton *back = [UIButton buttonWithType:UIButtonTypeSystem];
32 | back.backgroundColor = [UIColor grayColor];
33 | [back setTitle:@"返回" forState:UIControlStateNormal];
34 | back.frame = CGRectMake(100, 100, 50, 50);
35 | [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
36 | [self.view addSubview:back];
37 |
38 |
39 |
40 | UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
41 | button.backgroundColor = [UIColor grayColor];
42 | [button setTitle:@"下一个" forState:UIControlStateNormal];
43 | button.frame = CGRectMake(200, 100, 50, 50);
44 | [button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
45 | [self.view addSubview:button];
46 |
47 |
48 | UILabel *label = [[UILabel alloc]init];
49 | label.text = @"D";
50 | label.textAlignment = NSTextAlignmentCenter;
51 | label.frame = CGRectMake(0, 250, 320, 50);
52 | [self.view addSubview:label];
53 |
54 | }
55 |
56 | - (void)jump
57 | {
58 | [YQNavigator showViewControllerToURL:EVC_URL from:self];
59 | }
60 |
61 |
62 | - (void)didReceiveMemoryWarning
63 | {
64 | [super didReceiveMemoryWarning];
65 | // Dispose of any resources that can be recreated.
66 | }
67 |
68 | /*
69 | #pragma mark - Navigation
70 |
71 | // In a storyboard-based application, you will often want to do a little preparation before navigation
72 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
73 | {
74 | // Get the new view controller using [segue destinationViewController].
75 | // Pass the selected object to the new view controller.
76 | }
77 | */
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/URLNavigation/CViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // CViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "CViewController.h"
10 |
11 | @interface CViewController ()
12 |
13 | @end
14 |
15 | @implementation CViewController
16 |
17 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
18 | {
19 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
20 | if (self) {
21 | // Custom initialization
22 | }
23 | return self;
24 | }
25 |
26 | - (void)viewDidLoad
27 | {
28 | [super viewDidLoad];
29 | // Do any additional setup after loading the view.
30 |
31 | UIButton *back = [UIButton buttonWithType:UIButtonTypeSystem];
32 | back.backgroundColor = [UIColor grayColor];
33 | [back setTitle:@"返回" forState:UIControlStateNormal];
34 | back.frame = CGRectMake(100, 100, 50, 50);
35 | [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
36 | [self.view addSubview:back];
37 |
38 |
39 |
40 |
41 |
42 |
43 | UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
44 | button.backgroundColor = [UIColor grayColor];
45 | [button setTitle:@"下一个" forState:UIControlStateNormal];
46 | button.frame = CGRectMake(200, 100, 50, 50);
47 | [button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
48 | [self.view addSubview:button];
49 |
50 |
51 | UILabel *label = [[UILabel alloc]init];
52 | label.text = @"C";
53 | label.textAlignment = NSTextAlignmentCenter;
54 | label.frame = CGRectMake(0, 250, 320, 50);
55 | [self.view addSubview:label];
56 | }
57 |
58 | - (void)jump
59 | {
60 | [YQNavigator showViewControllerToURL:DVC_URL from:self];
61 | }
62 |
63 | - (void)didReceiveMemoryWarning
64 | {
65 | [super didReceiveMemoryWarning];
66 | // Dispose of any resources that can be recreated.
67 | }
68 |
69 | /*
70 | #pragma mark - Navigation
71 |
72 | // In a storyboard-based application, you will often want to do a little preparation before navigation
73 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
74 | {
75 | // Get the new view controller using [segue destinationViewController].
76 | // Pass the selected object to the new view controller.
77 | }
78 | */
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/URLNavigation/BViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // BViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "BViewController.h"
10 | #import "Sample.h"
11 |
12 | @interface BViewController ()
13 |
14 | @end
15 |
16 | @implementation BViewController
17 |
18 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
19 | {
20 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
21 | if (self) {
22 | // Custom initialization
23 | }
24 | return self;
25 | }
26 |
27 |
28 | - (void)loadMessageID:(NSNumber *)messageID
29 | {
30 | Sample *sampe = [Sample syncFetchBy:messageID];
31 | NSLog(@"sample content :: %@",sampe.messageContent);
32 | }
33 |
34 |
35 |
36 | - (void)viewDidLoad
37 | {
38 | [super viewDidLoad];
39 | // Do any additional setup after loading the view.
40 |
41 | UIButton *back = [UIButton buttonWithType:UIButtonTypeSystem];
42 | back.backgroundColor = [UIColor grayColor];
43 | [back setTitle:@"返回" forState:UIControlStateNormal];
44 | back.frame = CGRectMake(100, 100, 50, 50);
45 | [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
46 | [self.view addSubview:back];
47 |
48 |
49 | UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
50 | button.backgroundColor = [UIColor grayColor];
51 | [button setTitle:@"下一个" forState:UIControlStateNormal];
52 | button.frame = CGRectMake(200, 100, 50, 50);
53 | [button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
54 | [self.view addSubview:button];
55 |
56 |
57 | UILabel *label = [[UILabel alloc]init];
58 | label.text = @"B";
59 | label.textAlignment = NSTextAlignmentCenter;
60 | label.frame = CGRectMake(0, 250, 320, 50);
61 | [self.view addSubview:label];
62 |
63 | }
64 |
65 | - (void)jump
66 | {
67 | [YQNavigator showViewControllerToURL:CVC_URL from:self];
68 | }
69 |
70 |
71 |
72 | - (void)didReceiveMemoryWarning
73 | {
74 | [super didReceiveMemoryWarning];
75 | // Dispose of any resources that can be recreated.
76 | }
77 |
78 | /*
79 | #pragma mark - Navigation
80 |
81 | // In a storyboard-based application, you will often want to do a little preparation before navigation
82 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
83 | {
84 | // Get the new view controller using [segue destinationViewController].
85 | // Pass the selected object to the new view controller.
86 | }
87 | */
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/URLNavigation/YQNavigator.m:
--------------------------------------------------------------------------------
1 | //
2 | // YQNavigator.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "YQNavigator.h"
10 |
11 | #import "NSString+YQ.h"
12 | #import "YQDefine.h"
13 | #import "ViewControllers.h"
14 |
15 | @implementation YQNavigator
16 | + (void)showViewControllerToURL:(NSString*)aURL from:(YQBaseViewController *)aViewController
17 | {
18 |
19 |
20 | NSLog(@"open url %@",aURL);
21 |
22 | if (aURL && 0 < [aURL length]) {
23 | NSDictionary *urlDict = [aURL paramsFromURL];
24 | if ([YQPROTOCOL isEqual:[urlDict objectForKey:PROTOCOL]]) {
25 |
26 | if ([AVC isEqual:[urlDict objectForKey:HOST]]) {
27 | AViewController *aVC = [[AViewController alloc]init];
28 | aVC.yqNavigationController = aViewController.yqNavigationController;
29 | [aViewController.yqNavigationController pushViewController:aVC animated:YES];
30 | }
31 |
32 | if ([BVC isEqual:[urlDict objectForKey:HOST]]) {
33 | NSNumber *messageID = [[urlDict objectForKey:PARAMS] objectForKey:@"messageID"];
34 |
35 | NSLog(@"sssss :: %@",messageID);
36 | BViewController *aVC = [[BViewController alloc]init];
37 | [aVC loadMessageID:messageID];
38 | aVC.yqNavigationController = aViewController.yqNavigationController;
39 | [aViewController.yqNavigationController pushViewController:aVC animated:YES];
40 | }
41 |
42 | if ([CVC isEqual:[urlDict objectForKey:HOST]]) {
43 | CViewController *aVC = [[CViewController alloc]init];
44 | aVC.yqNavigationController = aViewController.yqNavigationController;
45 | [aViewController.yqNavigationController pushViewController:aVC animated:YES];
46 | }
47 |
48 | if ([DVC isEqual:[urlDict objectForKey:HOST]]) {
49 | DViewController *aVC = [[DViewController alloc]init];
50 | aVC.yqNavigationController = aViewController.yqNavigationController;
51 | [aViewController.yqNavigationController pushViewController:aVC animated:YES];
52 | }
53 |
54 | if ([EVC isEqual:[urlDict objectForKey:HOST]]) {
55 | EViewController *aVC = [[EViewController alloc]init];
56 | aVC.yqNavigationController = aViewController.yqNavigationController;
57 | [aViewController.yqNavigationController pushViewController:aVC animated:YES];
58 | }
59 | }
60 | }
61 | }
62 |
63 |
64 | @end
65 |
--------------------------------------------------------------------------------
/URLNavigation/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "YQNavigationViewController.h"
11 | #import "AViewController.h"
12 | #import "YQDBCenter.h"
13 |
14 | @interface AppDelegate()
15 | @property (nonatomic,strong) AViewController *firstVC;
16 |
17 | @end
18 |
19 |
20 | @implementation AppDelegate
21 |
22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
23 | {
24 | // Override point for customization after application launch.
25 |
26 |
27 | AViewController *aVC = [[AViewController alloc]init];
28 |
29 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
30 |
31 |
32 | YQNavigationViewController *nav = [[YQNavigationViewController alloc] initWithRootViewController:aVC];
33 | nav.navigationBarHidden = YES;
34 | //所有的VC 都使用这个NAV
35 | aVC.yqNavigationController = nav;
36 | self.window.rootViewController=nav;
37 | [self.window makeKeyAndVisible];
38 |
39 |
40 |
41 | [YQDBCenter shareDatabase];
42 |
43 | return YES;
44 | }
45 |
46 | - (void)applicationWillResignActive:(UIApplication *)application
47 | {
48 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
49 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
50 | }
51 |
52 | - (void)applicationDidEnterBackground:(UIApplication *)application
53 | {
54 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
55 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
56 | }
57 |
58 | - (void)applicationWillEnterForeground:(UIApplication *)application
59 | {
60 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
61 | }
62 |
63 | - (void)applicationDidBecomeActive:(UIApplication *)application
64 | {
65 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
66 | }
67 |
68 | - (void)applicationWillTerminate:(UIApplication *)application
69 | {
70 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
71 | }
72 |
73 | @end
74 |
--------------------------------------------------------------------------------
/URLNavigation/AViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // AViewController.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-21.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "AViewController.h"
10 | #import "Sample.h"
11 | #import "NSString+YQ.h"
12 | @interface AViewController ()
13 |
14 | @end
15 |
16 | @implementation AViewController
17 |
18 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
19 | {
20 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
21 | if (self) {
22 | // Custom initialization
23 | }
24 | return self;
25 | }
26 |
27 | - (void)viewDidLoad
28 | {
29 | [super viewDidLoad];
30 | // Do any additional setup after loading the view.
31 |
32 | UIButton *back = [UIButton buttonWithType:UIButtonTypeSystem];
33 | back.backgroundColor = [UIColor grayColor];
34 | [back setTitle:@"返回" forState:UIControlStateNormal];
35 | back.frame = CGRectMake(80, 100, 50, 50);
36 | [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
37 | [self.view addSubview:back];
38 |
39 |
40 |
41 |
42 |
43 |
44 | UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
45 | button.backgroundColor = [UIColor grayColor];
46 | [button setTitle:@"下一个" forState:UIControlStateNormal];
47 | button.frame = CGRectMake(320 - 80 - 50, 100, 50, 50);
48 | [button addTarget:self action:@selector(jump) forControlEvents:UIControlEventTouchUpInside];
49 | [self.view addSubview:button];
50 |
51 | //人为创建一个对象
52 |
53 | _sample = [[Sample alloc]init];
54 | _sample.messageID = @123;
55 | _sample.messageContent = @"hello Jasper";
56 |
57 | [_sample syncSave];
58 |
59 |
60 | UILabel *label = [[UILabel alloc]init];
61 | label.text = @"A";
62 | label.textAlignment = NSTextAlignmentCenter;
63 | label.frame = CGRectMake(0, 250, 320, 50);
64 | [self.view addSubview:label];
65 |
66 |
67 | }
68 |
69 | - (void)jump
70 | {
71 |
72 | //创建URL
73 | NSString *baseURLforBVC = BVC_URL;
74 | //增加参数
75 | NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
76 |
77 | //这里出了一个小问题,直接存 NSNumber 有点小问题
78 | [dict setValue:[NSString stringWithFormat:@"%@",_sample.messageID] forKey:@"messageID"];
79 |
80 | baseURLforBVC = [baseURLforBVC addUrlFromDictionary:dict];
81 | [YQNavigator showViewControllerToURL:baseURLforBVC from:self];
82 |
83 | }
84 |
85 |
86 |
87 |
88 |
89 | - (void)didReceiveMemoryWarning
90 | {
91 | [super didReceiveMemoryWarning];
92 | // Dispose of any resources that can be recreated.
93 | }
94 |
95 | /*
96 | #pragma mark - Navigation
97 |
98 | // In a storyboard-based application, you will often want to do a little preparation before navigation
99 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
100 | {
101 | // Get the new view controller using [segue destinationViewController].
102 | // Pass the selected object to the new view controller.
103 | }
104 | */
105 |
106 | @end
107 |
--------------------------------------------------------------------------------
/URLNavigation/Sample.m:
--------------------------------------------------------------------------------
1 | //
2 | // Sample.m
3 | // URLNavigation
4 | //
5 | // Created by Jasper on 14-7-22.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "Sample.h"
10 | #import "YQDBCenter.h"
11 | #import "YQCacheCenter.h"
12 |
13 | @interface Sample()
14 | //从数据库查询的对象中解析出一个sample对象
15 | + (Sample *)objectFromDBResultSet:(FMResultSet*)res;
16 | @end
17 |
18 |
19 | @implementation Sample
20 | @synthesize messageID = _messageID;
21 | @synthesize messageContent = _messageContent;
22 |
23 | //同步存储
24 | - (void)syncSave
25 | {
26 | //存缓存
27 | [[YQCacheCenter shareCacheCenter].mainCache setObject:self forKey:self.messageID];
28 |
29 | //存数据库
30 | FMDatabase *db = [YQDBCenter syncDB];
31 | [Sample saveSample:self forDB:db];
32 | }
33 |
34 | //异步存储
35 | - (void)asyncSave
36 | {
37 | //存缓存
38 | [[YQCacheCenter shareCacheCenter].mainCache setObject:self forKey:self.messageID];
39 | //存数据库
40 | [[YQDBCenter dbQueue]inDatabase:^(FMDatabase *db){
41 | [Sample saveSample:self forDB:db];
42 | }];
43 | }
44 |
45 | //同步获取
46 | + (Sample *)syncFetchBy:(NSNumber *)messageID
47 | {
48 | //先从缓存查找
49 | Sample *sample = nil;
50 | sample = [[YQCacheCenter shareCacheCenter].mainCache objectForKey:messageID];
51 | if (!sample) {
52 | //后从数据库查找
53 | FMDatabase *db = [YQDBCenter syncDB];
54 | sample = [Sample objectFromDB:db byMessageID:messageID];
55 | }
56 | return sample;
57 | }
58 |
59 | //异步获取
60 | + (void)asyncFetchBy:(NSNumber *)messageID doneBlock:(void (^)(Sample *))doneBlock
61 | {
62 | Sample *sample = nil;
63 | sample = [[YQCacheCenter shareCacheCenter].mainCache objectForKey:messageID];
64 | //先从缓存查找
65 | if (sample) {
66 | doneBlock(sample);
67 | }else{
68 | //后从数据库查找
69 | [[YQDBCenter dbQueue]inDatabase:^(FMDatabase *db){
70 | doneBlock([Sample objectFromDB:db byMessageID:messageID]);
71 | }];
72 | }
73 | }
74 | #pragma mark - db base operation
75 |
76 | + (NSString *)creatSampleStructureforDB
77 | {
78 | NSString *sql = @"CREATE TABLE IF NOT EXISTS 'message'('messageID' INTEGER PRIMARY KEY NOT NULL UNIQUE,'messageContent' TEXT)";
79 | return sql;
80 | }
81 |
82 |
83 | + (void)saveSample:(Sample *)sample forDB:(FMDatabase *)db
84 | {
85 | [db open];
86 | NSString *insertStr = @"REPLACE INTO 'message'(messageID,messageContent) VALUES (?,?)";
87 | [db executeUpdate:insertStr,sample.messageID,sample.messageContent];
88 | [db close];
89 | }
90 |
91 |
92 | + (Sample *)objectFromDB:(FMDatabase *)db byMessageID:(NSNumber *)messageID
93 | {
94 | [db open];
95 | Sample *sample = nil;
96 | NSString *isExistSql = [[NSString alloc]initWithFormat:@"select * from message where messageID = '%@'",messageID];
97 | FMResultSet *rs =[db executeQuery:isExistSql,nil];
98 | while ([rs next]) {
99 | sample = [Sample objectFromDBResultSet:rs];
100 | }
101 | [rs close];
102 | [db close];
103 | return sample;
104 | }
105 |
106 | + (Sample *)objectFromDBResultSet:(FMResultSet*)res
107 | {
108 | Sample *sample = [[Sample alloc]init];
109 | sample.messageID = [res objectForColumnName:@"messageID"];
110 | sample.messageContent = [res objectForColumnName:@"messageContent"];
111 | return sample;
112 | }
113 |
114 |
115 | @end
116 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/extra/FMDatabase+InMemoryOnDiskIO.m:
--------------------------------------------------------------------------------
1 | #import "FMDatabase+InMemoryOnDiskIO.h"
2 |
3 | // http://www.sqlite.org/backup.html
4 | static
5 | int loadOrSaveDb(sqlite3 *pInMemory, const char *zFilename, int isSave)
6 | {
7 | int rc; /* Function return code */
8 | sqlite3 *pFile; /* Database connection opened on zFilename */
9 | sqlite3_backup *pBackup; /* Backup object used to copy data */
10 | sqlite3 *pTo; /* Database to copy to (pFile or pInMemory) */
11 | sqlite3 *pFrom; /* Database to copy from (pFile or pInMemory) */
12 |
13 | /* Open the database file identified by zFilename. Exit early if this fails
14 | ** for any reason. */
15 | rc = sqlite3_open(zFilename, &pFile);
16 | if( rc==SQLITE_OK ){
17 |
18 | /* If this is a 'load' operation (isSave==0), then data is copied
19 | ** from the database file just opened to database pInMemory.
20 | ** Otherwise, if this is a 'save' operation (isSave==1), then data
21 | ** is copied from pInMemory to pFile. Set the variables pFrom and
22 | ** pTo accordingly. */
23 | pFrom = (isSave ? pInMemory : pFile);
24 | pTo = (isSave ? pFile : pInMemory);
25 |
26 | /* Set up the backup procedure to copy from the "main" database of
27 | ** connection pFile to the main database of connection pInMemory.
28 | ** If something goes wrong, pBackup will be set to NULL and an error
29 | ** code and message left in connection pTo.
30 | **
31 | ** If the backup object is successfully created, call backup_step()
32 | ** to copy data from pFile to pInMemory. Then call backup_finish()
33 | ** to release resources associated with the pBackup object. If an
34 | ** error occurred, then an error code and message will be left in
35 | ** connection pTo. If no error occurred, then the error code belonging
36 | ** to pTo is set to SQLITE_OK.
37 | */
38 | pBackup = sqlite3_backup_init(pTo, "main", pFrom, "main");
39 | if( pBackup ){
40 | (void)sqlite3_backup_step(pBackup, -1);
41 | (void)sqlite3_backup_finish(pBackup);
42 | }
43 | rc = sqlite3_errcode(pTo);
44 | }
45 |
46 | /* Close the database connection opened on database file zFilename
47 | ** and return the result of this function. */
48 | (void)sqlite3_close(pFile);
49 | return rc;
50 | }
51 |
52 |
53 |
54 | @implementation FMDatabase (InMemoryOnDiskIO)
55 |
56 | - (BOOL)readFromFile:(NSString*)filePath
57 | {
58 | // only attempt to load an on-disk representation for an in-memory database
59 | if ( self->_databasePath != nil )
60 | {
61 | NSLog(@"Database is not an in-memory representation." );
62 | return NO;
63 | }
64 |
65 | // and only if the database is open
66 | if ( self->_db == nil )
67 | {
68 | NSLog(@"Invalid database connection." );
69 | return NO;
70 | }
71 |
72 | return ( SQLITE_OK == loadOrSaveDb( self->_db, [filePath fileSystemRepresentation], false ) );
73 |
74 | }
75 |
76 | - (BOOL)writeToFile:(NSString *)filePath
77 | {
78 | // only attempt to save an on-disk representation for an in-memory database
79 | if ( self->_databasePath != nil )
80 | {
81 | NSLog(@"Database is not an in-memory representation." );
82 | return NO;
83 | }
84 |
85 | // and only if the database is open
86 | if ( self->_db == nil )
87 | {
88 | NSLog(@"Invalid database connection." );
89 | return NO;
90 | }
91 |
92 | // save the in-memory representation
93 | return ( SQLITE_OK == loadOrSaveDb( self->_db, [filePath fileSystemRepresentation], true ) );
94 | }
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/xcuserdata/jasper.xcuserdatad/xcschemes/URLNavigation.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
61 |
62 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabasePool.h:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabasePool.h
3 | // fmdb
4 | //
5 | // Created by August Mueller on 6/22/11.
6 | // Copyright 2011 Flying Meat Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "sqlite3.h"
11 |
12 | @class FMDatabase;
13 |
14 | /** Pool of `` objects.
15 |
16 | ### See also
17 |
18 | - ``
19 | - ``
20 |
21 | @warning Before using `FMDatabasePool`, please consider using `` instead.
22 |
23 | If you really really really know what you're doing and `FMDatabasePool` is what
24 | you really really need (ie, you're using a read only database), OK you can use
25 | it. But just be careful not to deadlock!
26 |
27 | For an example on deadlocking, search for:
28 | `ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS_OTHERWISE_YOULL_DEADLOCK_USE_FMDATABASEQUEUE_INSTEAD`
29 | in the main.m file.
30 | */
31 |
32 | @interface FMDatabasePool : NSObject {
33 | NSString *_path;
34 |
35 | dispatch_queue_t _lockQueue;
36 |
37 | NSMutableArray *_databaseInPool;
38 | NSMutableArray *_databaseOutPool;
39 |
40 | __unsafe_unretained id _delegate;
41 |
42 | NSUInteger _maximumNumberOfDatabasesToCreate;
43 | int _openFlags;
44 | }
45 |
46 | /** Database path */
47 |
48 | @property (atomic, retain) NSString *path;
49 |
50 | /** Delegate object */
51 |
52 | @property (atomic, assign) id delegate;
53 |
54 | /** Maximum number of databases to create */
55 |
56 | @property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate;
57 |
58 | /** Open flags */
59 |
60 | @property (atomic, readonly) int openFlags;
61 |
62 |
63 | ///---------------------
64 | /// @name Initialization
65 | ///---------------------
66 |
67 | /** Create pool using path.
68 |
69 | @param aPath The file path of the database.
70 |
71 | @return The `FMDatabasePool` object. `nil` on error.
72 | */
73 |
74 | + (instancetype)databasePoolWithPath:(NSString*)aPath;
75 |
76 | /** Create pool using path and specified flags
77 |
78 | @param aPath The file path of the database.
79 | @param openFlags Flags passed to the openWithFlags method of the database
80 |
81 | @return The `FMDatabasePool` object. `nil` on error.
82 | */
83 |
84 | + (instancetype)databasePoolWithPath:(NSString*)aPath flags:(int)openFlags;
85 |
86 | /** Create pool using path.
87 |
88 | @param aPath The file path of the database.
89 |
90 | @return The `FMDatabasePool` object. `nil` on error.
91 | */
92 |
93 | - (instancetype)initWithPath:(NSString*)aPath;
94 |
95 | /** Create pool using path and specified flags.
96 |
97 | @param aPath The file path of the database.
98 | @param openFlags Flags passed to the openWithFlags method of the database
99 |
100 | @return The `FMDatabasePool` object. `nil` on error.
101 | */
102 |
103 | - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
104 |
105 | ///------------------------------------------------
106 | /// @name Keeping track of checked in/out databases
107 | ///------------------------------------------------
108 |
109 | /** Number of checked-in databases in pool
110 |
111 | @returns Number of databases
112 | */
113 |
114 | - (NSUInteger)countOfCheckedInDatabases;
115 |
116 | /** Number of checked-out databases in pool
117 |
118 | @returns Number of databases
119 | */
120 |
121 | - (NSUInteger)countOfCheckedOutDatabases;
122 |
123 | /** Total number of databases in pool
124 |
125 | @returns Number of databases
126 | */
127 |
128 | - (NSUInteger)countOfOpenDatabases;
129 |
130 | /** Release all databases in pool */
131 |
132 | - (void)releaseAllDatabases;
133 |
134 | ///------------------------------------------
135 | /// @name Perform database operations in pool
136 | ///------------------------------------------
137 |
138 | /** Synchronously perform database operations in pool.
139 |
140 | @param block The code to be run on the `FMDatabasePool` pool.
141 | */
142 |
143 | - (void)inDatabase:(void (^)(FMDatabase *db))block;
144 |
145 | /** Synchronously perform database operations in pool using transaction.
146 |
147 | @param block The code to be run on the `FMDatabasePool` pool.
148 | */
149 |
150 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
151 |
152 | /** Synchronously perform database operations in pool using deferred transaction.
153 |
154 | @param block The code to be run on the `FMDatabasePool` pool.
155 | */
156 |
157 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
158 |
159 | #if SQLITE_VERSION_NUMBER >= 3007000
160 |
161 | /** Synchronously perform database operations in pool using save point.
162 |
163 | @param block The code to be run on the `FMDatabasePool` pool.
164 |
165 | @return `NSError` object if error; `nil` if successful.
166 |
167 | @warning You can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. If you need to nest, use `<[FMDatabase startSavePointWithName:error:]>` instead.
168 | */
169 |
170 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
171 | #endif
172 |
173 | @end
174 |
175 |
176 | /** FMDatabasePool delegate category
177 |
178 | This is a category that defines the protocol for the FMDatabasePool delegate
179 | */
180 |
181 | @interface NSObject (FMDatabasePoolDelegate)
182 |
183 | /** Asks the delegate whether database should be added to the pool.
184 |
185 | @param pool The `FMDatabasePool` object.
186 | @param database The `FMDatabase` object.
187 |
188 | @return `YES` if it should add database to pool; `NO` if not.
189 |
190 | */
191 |
192 | - (BOOL)databasePool:(FMDatabasePool*)pool shouldAddDatabaseToPool:(FMDatabase*)database;
193 |
194 | /** Tells the delegate that database was added to the pool.
195 |
196 | @param pool The `FMDatabasePool` object.
197 | @param database The `FMDatabase` object.
198 |
199 | */
200 |
201 | - (void)databasePool:(FMDatabasePool*)pool didAddDatabase:(FMDatabase*)database;
202 |
203 | @end
204 |
205 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabaseQueue.h:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabaseQueue.h
3 | // fmdb
4 | //
5 | // Created by August Mueller on 6/22/11.
6 | // Copyright 2011 Flying Meat Inc. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "sqlite3.h"
11 |
12 | @class FMDatabase;
13 |
14 | /** To perform queries and updates on multiple threads, you'll want to use `FMDatabaseQueue`.
15 |
16 | Using a single instance of `` from multiple threads at once is a bad idea. It has always been OK to make a `` object *per thread*. Just don't share a single instance across threads, and definitely not across multiple threads at the same time.
17 |
18 | Instead, use `FMDatabaseQueue`. Here's how to use it:
19 |
20 | First, make your queue.
21 |
22 | FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:aPath];
23 |
24 | Then use it like so:
25 |
26 | [queue inDatabase:^(FMDatabase *db) {
27 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
28 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
29 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
30 |
31 | FMResultSet *rs = [db executeQuery:@"select * from foo"];
32 | while ([rs next]) {
33 | //…
34 | }
35 | }];
36 |
37 | An easy way to wrap things up in a transaction can be done like this:
38 |
39 | [queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
40 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
41 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
42 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
43 |
44 | if (whoopsSomethingWrongHappened) {
45 | *rollback = YES;
46 | return;
47 | }
48 | // etc…
49 | [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:4]];
50 | }];
51 |
52 | `FMDatabaseQueue` will run the blocks on a serialized queue (hence the name of the class). So if you call `FMDatabaseQueue`'s methods from multiple threads at the same time, they will be executed in the order they are received. This way queries and updates won't step on each other's toes, and every one is happy.
53 |
54 | ### See also
55 |
56 | - ``
57 |
58 | @warning Do not instantiate a single `` object and use it across multiple threads. Use `FMDatabaseQueue` instead.
59 |
60 | @warning The calls to `FMDatabaseQueue`'s methods are blocking. So even though you are passing along blocks, they will **not** be run on another thread.
61 |
62 | */
63 |
64 | @interface FMDatabaseQueue : NSObject {
65 | NSString *_path;
66 | dispatch_queue_t _queue;
67 | FMDatabase *_db;
68 | int _openFlags;
69 | }
70 |
71 | /** Path of database */
72 |
73 | @property (atomic, retain) NSString *path;
74 |
75 | /** Open flags */
76 |
77 | @property (atomic, readonly) int openFlags;
78 |
79 | ///----------------------------------------------------
80 | /// @name Initialization, opening, and closing of queue
81 | ///----------------------------------------------------
82 |
83 | /** Create queue using path.
84 |
85 | @param aPath The file path of the database.
86 |
87 | @return The `FMDatabaseQueue` object. `nil` on error.
88 | */
89 |
90 | + (instancetype)databaseQueueWithPath:(NSString*)aPath;
91 |
92 | /** Create queue using path and specified flags.
93 |
94 | @param aPath The file path of the database.
95 | @param openFlags Flags passed to the openWithFlags method of the database
96 |
97 | @return The `FMDatabaseQueue` object. `nil` on error.
98 | */
99 | + (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags;
100 |
101 | /** Create queue using path.
102 |
103 | @param aPath The file path of the database.
104 |
105 | @return The `FMDatabaseQueue` object. `nil` on error.
106 | */
107 |
108 | - (instancetype)initWithPath:(NSString*)aPath;
109 |
110 | /** Create queue using path and specified flags.
111 |
112 | @param aPath The file path of the database.
113 | @param openFlags Flags passed to the openWithFlags method of the database
114 |
115 | @return The `FMDatabaseQueue` object. `nil` on error.
116 | */
117 |
118 | - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
119 |
120 | /** Returns the Class of 'FMDatabase' subclass, that will be used to instantiate database object.
121 |
122 | Subclasses can override this method to return specified Class of 'FMDatabase' subclass.
123 |
124 | @return The Class of 'FMDatabase' subclass, that will be used to instantiate database object.
125 | */
126 |
127 | + (Class)databaseClass;
128 |
129 | /** Close database used by queue. */
130 |
131 | - (void)close;
132 |
133 | ///-----------------------------------------------
134 | /// @name Dispatching database operations to queue
135 | ///-----------------------------------------------
136 |
137 | /** Synchronously perform database operations on queue.
138 |
139 | @param block The code to be run on the queue of `FMDatabaseQueue`
140 | */
141 |
142 | - (void)inDatabase:(void (^)(FMDatabase *db))block;
143 |
144 | /** Synchronously perform database operations on queue, using transactions.
145 |
146 | @param block The code to be run on the queue of `FMDatabaseQueue`
147 | */
148 |
149 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
150 |
151 | /** Synchronously perform database operations on queue, using deferred transactions.
152 |
153 | @param block The code to be run on the queue of `FMDatabaseQueue`
154 | */
155 |
156 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
157 |
158 | ///-----------------------------------------------
159 | /// @name Dispatching database operations to queue
160 | ///-----------------------------------------------
161 |
162 | /** Synchronously perform database operations using save point.
163 |
164 | @param block The code to be run on the queue of `FMDatabaseQueue`
165 | */
166 |
167 | #if SQLITE_VERSION_NUMBER >= 3007000
168 | // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock.
169 | // If you need to nest, use FMDatabase's startSavePointWithName:error: instead.
170 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
171 | #endif
172 |
173 | @end
174 |
175 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabaseQueue.m:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabaseQueue.m
3 | // fmdb
4 | //
5 | // Created by August Mueller on 6/22/11.
6 | // Copyright 2011 Flying Meat Inc. All rights reserved.
7 | //
8 |
9 | #import "FMDatabaseQueue.h"
10 | #import "FMDatabase.h"
11 |
12 | /*
13 |
14 | Note: we call [self retain]; before using dispatch_sync, just incase
15 | FMDatabaseQueue is released on another thread and we're in the middle of doing
16 | something in dispatch_sync
17 |
18 | */
19 |
20 | /*
21 | * A key used to associate the FMDatabaseQueue object with the dispatch_queue_t it uses.
22 | * This in turn is used for deadlock detection by seeing if inDatabase: is called on
23 | * the queue's dispatch queue, which should not happen and causes a deadlock.
24 | */
25 | static const void * const kDispatchQueueSpecificKey = &kDispatchQueueSpecificKey;
26 |
27 | @implementation FMDatabaseQueue
28 |
29 | @synthesize path = _path;
30 | @synthesize openFlags = _openFlags;
31 |
32 | + (instancetype)databaseQueueWithPath:(NSString*)aPath {
33 |
34 | FMDatabaseQueue *q = [[self alloc] initWithPath:aPath];
35 |
36 | FMDBAutorelease(q);
37 |
38 | return q;
39 | }
40 |
41 | + (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags {
42 |
43 | FMDatabaseQueue *q = [[self alloc] initWithPath:aPath flags:openFlags];
44 |
45 | FMDBAutorelease(q);
46 |
47 | return q;
48 | }
49 |
50 | + (Class)databaseClass {
51 | return [FMDatabase class];
52 | }
53 |
54 | - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
55 |
56 | self = [super init];
57 |
58 | if (self != nil) {
59 |
60 | _db = [[[self class] databaseClass] databaseWithPath:aPath];
61 | FMDBRetain(_db);
62 |
63 | #if SQLITE_VERSION_NUMBER >= 3005000
64 | BOOL success = [_db openWithFlags:openFlags];
65 | #else
66 | BOOL success = [_db open];
67 | #endif
68 | if (!success) {
69 | NSLog(@"Could not create database queue for path %@", aPath);
70 | FMDBRelease(self);
71 | return 0x00;
72 | }
73 |
74 | _path = FMDBReturnRetained(aPath);
75 |
76 | _queue = dispatch_queue_create([[NSString stringWithFormat:@"fmdb.%@", self] UTF8String], NULL);
77 | dispatch_queue_set_specific(_queue, kDispatchQueueSpecificKey, (__bridge void *)self, NULL);
78 | _openFlags = openFlags;
79 | }
80 |
81 | return self;
82 | }
83 |
84 | - (instancetype)initWithPath:(NSString*)aPath {
85 |
86 | // default flags for sqlite3_open
87 | return [self initWithPath:aPath flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE];
88 | }
89 |
90 | - (instancetype)init {
91 | return [self initWithPath:nil];
92 | }
93 |
94 |
95 | - (void)dealloc {
96 |
97 | FMDBRelease(_db);
98 | FMDBRelease(_path);
99 |
100 | if (_queue) {
101 | FMDBDispatchQueueRelease(_queue);
102 | _queue = 0x00;
103 | }
104 | #if ! __has_feature(objc_arc)
105 | [super dealloc];
106 | #endif
107 | }
108 |
109 | - (void)close {
110 | FMDBRetain(self);
111 | dispatch_sync(_queue, ^() {
112 | [_db close];
113 | FMDBRelease(_db);
114 | _db = 0x00;
115 | });
116 | FMDBRelease(self);
117 | }
118 |
119 | - (FMDatabase*)database {
120 | if (!_db) {
121 | _db = FMDBReturnRetained([FMDatabase databaseWithPath:_path]);
122 |
123 | #if SQLITE_VERSION_NUMBER >= 3005000
124 | BOOL success = [_db openWithFlags:_openFlags];
125 | #else
126 | BOOL success = [db open];
127 | #endif
128 | if (!success) {
129 | NSLog(@"FMDatabaseQueue could not reopen database for path %@", _path);
130 | FMDBRelease(_db);
131 | _db = 0x00;
132 | return 0x00;
133 | }
134 | }
135 |
136 | return _db;
137 | }
138 |
139 | - (void)inDatabase:(void (^)(FMDatabase *db))block {
140 | /* Get the currently executing queue (which should probably be nil, but in theory could be another DB queue
141 | * and then check it against self to make sure we're not about to deadlock. */
142 | FMDatabaseQueue *currentSyncQueue = (__bridge id)dispatch_get_specific(kDispatchQueueSpecificKey);
143 | assert(currentSyncQueue != self && "inDatabase: was called reentrantly on the same queue, which would lead to a deadlock");
144 |
145 | FMDBRetain(self);
146 |
147 | dispatch_sync(_queue, ^() {
148 |
149 | FMDatabase *db = [self database];
150 | block(db);
151 |
152 | if ([db hasOpenResultSets]) {
153 | NSLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]");
154 |
155 | #ifdef DEBUG
156 | NSSet *openSetCopy = FMDBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
157 | for (NSValue *rsInWrappedInATastyValueMeal in openSetCopy) {
158 | FMResultSet *rs = (FMResultSet *)[rsInWrappedInATastyValueMeal pointerValue];
159 | NSLog(@"query: '%@'", [rs query]);
160 | }
161 | #endif
162 | }
163 | });
164 |
165 | FMDBRelease(self);
166 | }
167 |
168 |
169 | - (void)beginTransaction:(BOOL)useDeferred withBlock:(void (^)(FMDatabase *db, BOOL *rollback))block {
170 | FMDBRetain(self);
171 | dispatch_sync(_queue, ^() {
172 |
173 | BOOL shouldRollback = NO;
174 |
175 | if (useDeferred) {
176 | [[self database] beginDeferredTransaction];
177 | }
178 | else {
179 | [[self database] beginTransaction];
180 | }
181 |
182 | block([self database], &shouldRollback);
183 |
184 | if (shouldRollback) {
185 | [[self database] rollback];
186 | }
187 | else {
188 | [[self database] commit];
189 | }
190 | });
191 |
192 | FMDBRelease(self);
193 | }
194 |
195 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
196 | [self beginTransaction:YES withBlock:block];
197 | }
198 |
199 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
200 | [self beginTransaction:NO withBlock:block];
201 | }
202 |
203 | #if SQLITE_VERSION_NUMBER >= 3007000
204 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
205 |
206 | static unsigned long savePointIdx = 0;
207 | __block NSError *err = 0x00;
208 | FMDBRetain(self);
209 | dispatch_sync(_queue, ^() {
210 |
211 | NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++];
212 |
213 | BOOL shouldRollback = NO;
214 |
215 | if ([[self database] startSavePointWithName:name error:&err]) {
216 |
217 | block([self database], &shouldRollback);
218 |
219 | if (shouldRollback) {
220 | // We need to rollback and release this savepoint to remove it
221 | [[self database] rollbackToSavePointWithName:name error:&err];
222 | }
223 | [[self database] releaseSavePointWithName:name error:&err];
224 |
225 | }
226 | });
227 | FMDBRelease(self);
228 | return err;
229 | }
230 | #endif
231 |
232 | @end
233 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabaseAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabaseAdditions.m
3 | // fmdb
4 | //
5 | // Created by August Mueller on 10/30/05.
6 | // Copyright 2005 Flying Meat Inc.. All rights reserved.
7 | //
8 |
9 | #import "FMDatabase.h"
10 | #import "FMDatabaseAdditions.h"
11 | #import "TargetConditionals.h"
12 |
13 | @interface FMDatabase (PrivateStuff)
14 | - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args;
15 | @end
16 |
17 | @implementation FMDatabase (FMDatabaseAdditions)
18 |
19 | #define RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(type, sel) \
20 | va_list args; \
21 | va_start(args, query); \
22 | FMResultSet *resultSet = [self executeQuery:query withArgumentsInArray:0x00 orDictionary:0x00 orVAList:args]; \
23 | va_end(args); \
24 | if (![resultSet next]) { return (type)0; } \
25 | type ret = [resultSet sel:0]; \
26 | [resultSet close]; \
27 | [resultSet setParentDB:nil]; \
28 | return ret;
29 |
30 |
31 | - (NSString*)stringForQuery:(NSString*)query, ... {
32 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSString *, stringForColumnIndex);
33 | }
34 |
35 | - (int)intForQuery:(NSString*)query, ... {
36 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(int, intForColumnIndex);
37 | }
38 |
39 | - (long)longForQuery:(NSString*)query, ... {
40 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(long, longForColumnIndex);
41 | }
42 |
43 | - (BOOL)boolForQuery:(NSString*)query, ... {
44 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(BOOL, boolForColumnIndex);
45 | }
46 |
47 | - (double)doubleForQuery:(NSString*)query, ... {
48 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(double, doubleForColumnIndex);
49 | }
50 |
51 | - (NSData*)dataForQuery:(NSString*)query, ... {
52 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSData *, dataForColumnIndex);
53 | }
54 |
55 | - (NSDate*)dateForQuery:(NSString*)query, ... {
56 | RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSDate *, dateForColumnIndex);
57 | }
58 |
59 |
60 | - (BOOL)tableExists:(NSString*)tableName {
61 |
62 | tableName = [tableName lowercaseString];
63 |
64 | FMResultSet *rs = [self executeQuery:@"select [sql] from sqlite_master where [type] = 'table' and lower(name) = ?", tableName];
65 |
66 | //if at least one next exists, table exists
67 | BOOL returnBool = [rs next];
68 |
69 | //close and free object
70 | [rs close];
71 |
72 | return returnBool;
73 | }
74 |
75 | /*
76 | get table with list of tables: result colums: type[STRING], name[STRING],tbl_name[STRING],rootpage[INTEGER],sql[STRING]
77 | check if table exist in database (patch from OZLB)
78 | */
79 | - (FMResultSet*)getSchema {
80 |
81 | //result colums: type[STRING], name[STRING],tbl_name[STRING],rootpage[INTEGER],sql[STRING]
82 | FMResultSet *rs = [self executeQuery:@"SELECT type, name, tbl_name, rootpage, sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type != 'meta' AND name NOT LIKE 'sqlite_%' ORDER BY tbl_name, type DESC, name"];
83 |
84 | return rs;
85 | }
86 |
87 | /*
88 | get table schema: result colums: cid[INTEGER], name,type [STRING], notnull[INTEGER], dflt_value[],pk[INTEGER]
89 | */
90 | - (FMResultSet*)getTableSchema:(NSString*)tableName {
91 |
92 | //result colums: cid[INTEGER], name,type [STRING], notnull[INTEGER], dflt_value[],pk[INTEGER]
93 | FMResultSet *rs = [self executeQuery:[NSString stringWithFormat: @"pragma table_info('%@')", tableName]];
94 |
95 | return rs;
96 | }
97 |
98 | - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName {
99 |
100 | BOOL returnBool = NO;
101 |
102 | tableName = [tableName lowercaseString];
103 | columnName = [columnName lowercaseString];
104 |
105 | FMResultSet *rs = [self getTableSchema:tableName];
106 |
107 | //check if column is present in table schema
108 | while ([rs next]) {
109 | if ([[[rs stringForColumn:@"name"] lowercaseString] isEqualToString:columnName]) {
110 | returnBool = YES;
111 | break;
112 | }
113 | }
114 |
115 | //If this is not done FMDatabase instance stays out of pool
116 | [rs close];
117 |
118 | return returnBool;
119 | }
120 |
121 |
122 | #if SQLITE_VERSION_NUMBER >= 3007017
123 |
124 | - (uint32_t)applicationID {
125 |
126 | uint32_t r = 0;
127 |
128 | FMResultSet *rs = [self executeQuery:@"pragma application_id"];
129 |
130 | if ([rs next]) {
131 | r = (uint32_t)[rs longLongIntForColumnIndex:0];
132 | }
133 |
134 | [rs close];
135 |
136 | return r;
137 | }
138 |
139 | - (void)setApplicationID:(uint32_t)appID {
140 | NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID];
141 | FMResultSet *rs = [self executeQuery:query];
142 | [rs next];
143 | [rs close];
144 | }
145 |
146 |
147 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE
148 | - (NSString*)applicationIDString {
149 | NSString *s = NSFileTypeForHFSTypeCode([self applicationID]);
150 |
151 | assert([s length] == 6);
152 |
153 | s = [s substringWithRange:NSMakeRange(1, 4)];
154 |
155 |
156 | return s;
157 |
158 | }
159 |
160 | - (void)setApplicationIDString:(NSString*)s {
161 |
162 | if ([s length] != 4) {
163 | NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
164 | }
165 |
166 | [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])];
167 | }
168 |
169 |
170 | #endif
171 |
172 | #endif
173 |
174 | - (uint32_t)userVersion {
175 | uint32_t r = 0;
176 |
177 | FMResultSet *rs = [self executeQuery:@"pragma user_version"];
178 |
179 | if ([rs next]) {
180 | r = (uint32_t)[rs longLongIntForColumnIndex:0];
181 | }
182 |
183 | [rs close];
184 | return r;
185 | }
186 |
187 | - (void)setUserVersion:(uint32_t)version {
188 | NSString *query = [NSString stringWithFormat:@"pragma user_version = %d", version];
189 | FMResultSet *rs = [self executeQuery:query];
190 | [rs next];
191 | [rs close];
192 | }
193 |
194 | #pragma clang diagnostic push
195 | #pragma clang diagnostic ignored "-Wdeprecated-implementations"
196 |
197 | - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated)) {
198 | return [self columnExists:columnName inTableWithName:tableName];
199 | }
200 |
201 | #pragma clang diagnostic pop
202 |
203 |
204 | - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error {
205 | sqlite3_stmt *pStmt = NULL;
206 | BOOL validationSucceeded = YES;
207 |
208 | int rc = sqlite3_prepare_v2(_db, [sql UTF8String], -1, &pStmt, 0);
209 | if (rc != SQLITE_OK) {
210 | validationSucceeded = NO;
211 | if (error) {
212 | *error = [NSError errorWithDomain:NSCocoaErrorDomain
213 | code:[self lastErrorCode]
214 | userInfo:[NSDictionary dictionaryWithObject:[self lastErrorMessage]
215 | forKey:NSLocalizedDescriptionKey]];
216 | }
217 | }
218 |
219 | sqlite3_finalize(pStmt);
220 |
221 | return validationSucceeded;
222 | }
223 |
224 | @end
225 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabaseAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabaseAdditions.h
3 | // fmdb
4 | //
5 | // Created by August Mueller on 10/30/05.
6 | // Copyright 2005 Flying Meat Inc.. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "FMDatabase.h"
11 |
12 |
13 | /** Category of additions for `` class.
14 |
15 | ### See also
16 |
17 | - ``
18 | */
19 |
20 | @interface FMDatabase (FMDatabaseAdditions)
21 |
22 | ///----------------------------------------
23 | /// @name Return results of SQL to variable
24 | ///----------------------------------------
25 |
26 | /** Return `int` value for query
27 |
28 | @param query The SQL query to be performed.
29 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
30 |
31 | @return `int` value.
32 | */
33 |
34 | - (int)intForQuery:(NSString*)query, ...;
35 |
36 | /** Return `long` value for query
37 |
38 | @param query The SQL query to be performed.
39 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
40 |
41 | @return `long` value.
42 | */
43 |
44 | - (long)longForQuery:(NSString*)query, ...;
45 |
46 | /** Return `BOOL` value for query
47 |
48 | @param query The SQL query to be performed.
49 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
50 |
51 | @return `BOOL` value.
52 | */
53 |
54 | - (BOOL)boolForQuery:(NSString*)query, ...;
55 |
56 | /** Return `double` value for query
57 |
58 | @param query The SQL query to be performed.
59 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
60 |
61 | @return `double` value.
62 | */
63 |
64 | - (double)doubleForQuery:(NSString*)query, ...;
65 |
66 | /** Return `NSString` value for query
67 |
68 | @param query The SQL query to be performed.
69 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
70 |
71 | @return `NSString` value.
72 | */
73 |
74 | - (NSString*)stringForQuery:(NSString*)query, ...;
75 |
76 | /** Return `NSData` value for query
77 |
78 | @param query The SQL query to be performed.
79 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
80 |
81 | @return `NSData` value.
82 | */
83 |
84 | - (NSData*)dataForQuery:(NSString*)query, ...;
85 |
86 | /** Return `NSDate` value for query
87 |
88 | @param query The SQL query to be performed.
89 | @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
90 |
91 | @return `NSDate` value.
92 | */
93 |
94 | - (NSDate*)dateForQuery:(NSString*)query, ...;
95 |
96 |
97 | // Notice that there's no dataNoCopyForQuery:.
98 | // That would be a bad idea, because we close out the result set, and then what
99 | // happens to the data that we just didn't copy? Who knows, not I.
100 |
101 |
102 | ///--------------------------------
103 | /// @name Schema related operations
104 | ///--------------------------------
105 |
106 | /** Does table exist in database?
107 |
108 | @param tableName The name of the table being looked for.
109 |
110 | @return `YES` if table found; `NO` if not found.
111 | */
112 |
113 | - (BOOL)tableExists:(NSString*)tableName;
114 |
115 | /** The schema of the database.
116 |
117 | This will be the schema for the entire database. For each entity, each row of the result set will include the following fields:
118 |
119 | - `type` - The type of entity (e.g. table, index, view, or trigger)
120 | - `name` - The name of the object
121 | - `tbl_name` - The name of the table to which the object references
122 | - `rootpage` - The page number of the root b-tree page for tables and indices
123 | - `sql` - The SQL that created the entity
124 |
125 | @return `FMResultSet` of schema; `nil` on error.
126 |
127 | @see [SQLite File Format](http://www.sqlite.org/fileformat.html)
128 | */
129 |
130 | - (FMResultSet*)getSchema;
131 |
132 | /** The schema of the database.
133 |
134 | This will be the schema for a particular table as report by SQLite `PRAGMA`, for example:
135 |
136 | PRAGMA table_info('employees')
137 |
138 | This will report:
139 |
140 | - `cid` - The column ID number
141 | - `name` - The name of the column
142 | - `type` - The data type specified for the column
143 | - `notnull` - whether the field is defined as NOT NULL (i.e. values required)
144 | - `dflt_value` - The default value for the column
145 | - `pk` - Whether the field is part of the primary key of the table
146 |
147 | @param tableName The name of the table for whom the schema will be returned.
148 |
149 | @return `FMResultSet` of schema; `nil` on error.
150 |
151 | @see [table_info](http://www.sqlite.org/pragma.html#pragma_table_info)
152 | */
153 |
154 | - (FMResultSet*)getTableSchema:(NSString*)tableName;
155 |
156 | /** Test to see if particular column exists for particular table in database
157 |
158 | @param columnName The name of the column.
159 |
160 | @param tableName The name of the table.
161 |
162 | @return `YES` if column exists in table in question; `NO` otherwise.
163 | */
164 |
165 | - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
166 |
167 | /** Test to see if particular column exists for particular table in database
168 |
169 | @param columnName The name of the column.
170 |
171 | @param tableName The name of the table.
172 |
173 | @return `YES` if column exists in table in question; `NO` otherwise.
174 |
175 | @see columnExists:inTableWithName:
176 |
177 | @warning Deprecated - use `` instead.
178 | */
179 |
180 | - (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated));
181 |
182 |
183 | /** Validate SQL statement
184 |
185 | This validates SQL statement by performing `sqlite3_prepare_v2`, but not returning the results, but instead immediately calling `sqlite3_finalize`.
186 |
187 | @param sql The SQL statement being validated.
188 |
189 | @param error This is a pointer to a `NSError` object that will receive the autoreleased `NSError` object if there was any error. If this is `nil`, no `NSError` result will be returned.
190 |
191 | @return `YES` if validation succeeded without incident; `NO` otherwise.
192 |
193 | */
194 |
195 | - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
196 |
197 |
198 | #if SQLITE_VERSION_NUMBER >= 3007017
199 |
200 | ///-----------------------------------
201 | /// @name Application identifier tasks
202 | ///-----------------------------------
203 |
204 | /** Retrieve application ID
205 |
206 | @return The `uint32_t` numeric value of the application ID.
207 |
208 | @see setApplicationID:
209 | */
210 |
211 | - (uint32_t)applicationID;
212 |
213 | /** Set the application ID
214 |
215 | @param appID The `uint32_t` numeric value of the application ID.
216 |
217 | @see applicationID
218 | */
219 |
220 | - (void)setApplicationID:(uint32_t)appID;
221 |
222 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE
223 | /** Retrieve application ID string
224 |
225 | @return The `NSString` value of the application ID.
226 |
227 | @see setApplicationIDString:
228 | */
229 |
230 |
231 | - (NSString*)applicationIDString;
232 |
233 | /** Set the application ID string
234 |
235 | @param string The `NSString` value of the application ID.
236 |
237 | @see applicationIDString
238 | */
239 |
240 | - (void)setApplicationIDString:(NSString*)string;
241 | #endif
242 |
243 | #endif
244 |
245 | ///-----------------------------------
246 | /// @name user version identifier tasks
247 | ///-----------------------------------
248 |
249 | /** Retrieve user version
250 |
251 | @return The `uint32_t` numeric value of the user version.
252 |
253 | @see setUserVersion:
254 | */
255 |
256 | - (uint32_t)userVersion;
257 |
258 | /** Set the user-version
259 |
260 | @param version The `uint32_t` numeric value of the user version.
261 |
262 | @see userVersion
263 | */
264 |
265 | - (void)setUserVersion:(uint32_t)version;
266 |
267 | @end
268 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabasePool.m:
--------------------------------------------------------------------------------
1 | //
2 | // FMDatabasePool.m
3 | // fmdb
4 | //
5 | // Created by August Mueller on 6/22/11.
6 | // Copyright 2011 Flying Meat Inc. All rights reserved.
7 | //
8 |
9 | #import "FMDatabasePool.h"
10 | #import "FMDatabase.h"
11 |
12 | @interface FMDatabasePool()
13 |
14 | - (void)pushDatabaseBackInPool:(FMDatabase*)db;
15 | - (FMDatabase*)db;
16 |
17 | @end
18 |
19 |
20 | @implementation FMDatabasePool
21 | @synthesize path=_path;
22 | @synthesize delegate=_delegate;
23 | @synthesize maximumNumberOfDatabasesToCreate=_maximumNumberOfDatabasesToCreate;
24 | @synthesize openFlags=_openFlags;
25 |
26 |
27 | + (instancetype)databasePoolWithPath:(NSString*)aPath {
28 | return FMDBReturnAutoreleased([[self alloc] initWithPath:aPath]);
29 | }
30 |
31 | + (instancetype)databasePoolWithPath:(NSString*)aPath flags:(int)openFlags {
32 | return FMDBReturnAutoreleased([[self alloc] initWithPath:aPath flags:openFlags]);
33 | }
34 |
35 | - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
36 |
37 | self = [super init];
38 |
39 | if (self != nil) {
40 | _path = [aPath copy];
41 | _lockQueue = dispatch_queue_create([[NSString stringWithFormat:@"fmdb.%@", self] UTF8String], NULL);
42 | _databaseInPool = FMDBReturnRetained([NSMutableArray array]);
43 | _databaseOutPool = FMDBReturnRetained([NSMutableArray array]);
44 | _openFlags = openFlags;
45 | }
46 |
47 | return self;
48 | }
49 |
50 | - (instancetype)initWithPath:(NSString*)aPath
51 | {
52 | // default flags for sqlite3_open
53 | return [self initWithPath:aPath flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE];
54 | }
55 |
56 | - (instancetype)init {
57 | return [self initWithPath:nil];
58 | }
59 |
60 |
61 | - (void)dealloc {
62 |
63 | _delegate = 0x00;
64 | FMDBRelease(_path);
65 | FMDBRelease(_databaseInPool);
66 | FMDBRelease(_databaseOutPool);
67 |
68 | if (_lockQueue) {
69 | FMDBDispatchQueueRelease(_lockQueue);
70 | _lockQueue = 0x00;
71 | }
72 | #if ! __has_feature(objc_arc)
73 | [super dealloc];
74 | #endif
75 | }
76 |
77 |
78 | - (void)executeLocked:(void (^)(void))aBlock {
79 | dispatch_sync(_lockQueue, aBlock);
80 | }
81 |
82 | - (void)pushDatabaseBackInPool:(FMDatabase*)db {
83 |
84 | if (!db) { // db can be null if we set an upper bound on the # of databases to create.
85 | return;
86 | }
87 |
88 | [self executeLocked:^() {
89 |
90 | if ([_databaseInPool containsObject:db]) {
91 | [[NSException exceptionWithName:@"Database already in pool" reason:@"The FMDatabase being put back into the pool is already present in the pool" userInfo:nil] raise];
92 | }
93 |
94 | [_databaseInPool addObject:db];
95 | [_databaseOutPool removeObject:db];
96 |
97 | }];
98 | }
99 |
100 | - (FMDatabase*)db {
101 |
102 | __block FMDatabase *db;
103 |
104 |
105 | [self executeLocked:^() {
106 | db = [_databaseInPool lastObject];
107 |
108 | BOOL shouldNotifyDelegate = NO;
109 |
110 | if (db) {
111 | [_databaseOutPool addObject:db];
112 | [_databaseInPool removeLastObject];
113 | }
114 | else {
115 |
116 | if (_maximumNumberOfDatabasesToCreate) {
117 | NSUInteger currentCount = [_databaseOutPool count] + [_databaseInPool count];
118 |
119 | if (currentCount >= _maximumNumberOfDatabasesToCreate) {
120 | NSLog(@"Maximum number of databases (%ld) has already been reached!", (long)currentCount);
121 | return;
122 | }
123 | }
124 |
125 | db = [FMDatabase databaseWithPath:_path];
126 | shouldNotifyDelegate = YES;
127 | }
128 |
129 | //This ensures that the db is opened before returning
130 | #if SQLITE_VERSION_NUMBER >= 3005000
131 | BOOL success = [db openWithFlags:_openFlags];
132 | #else
133 | BOOL success = [db open];
134 | #endif
135 | if (success) {
136 | if ([_delegate respondsToSelector:@selector(databasePool:shouldAddDatabaseToPool:)] && ![_delegate databasePool:self shouldAddDatabaseToPool:db]) {
137 | [db close];
138 | db = 0x00;
139 | }
140 | else {
141 | //It should not get added in the pool twice if lastObject was found
142 | if (![_databaseOutPool containsObject:db]) {
143 | [_databaseOutPool addObject:db];
144 |
145 | if (shouldNotifyDelegate && [_delegate respondsToSelector:@selector(databasePool:didAddDatabase:)]) {
146 | [_delegate databasePool:self didAddDatabase:db];
147 | }
148 | }
149 | }
150 | }
151 | else {
152 | NSLog(@"Could not open up the database at path %@", _path);
153 | db = 0x00;
154 | }
155 | }];
156 |
157 | return db;
158 | }
159 |
160 | - (NSUInteger)countOfCheckedInDatabases {
161 |
162 | __block NSUInteger count;
163 |
164 | [self executeLocked:^() {
165 | count = [_databaseInPool count];
166 | }];
167 |
168 | return count;
169 | }
170 |
171 | - (NSUInteger)countOfCheckedOutDatabases {
172 |
173 | __block NSUInteger count;
174 |
175 | [self executeLocked:^() {
176 | count = [_databaseOutPool count];
177 | }];
178 |
179 | return count;
180 | }
181 |
182 | - (NSUInteger)countOfOpenDatabases {
183 | __block NSUInteger count;
184 |
185 | [self executeLocked:^() {
186 | count = [_databaseOutPool count] + [_databaseInPool count];
187 | }];
188 |
189 | return count;
190 | }
191 |
192 | - (void)releaseAllDatabases {
193 | [self executeLocked:^() {
194 | [_databaseOutPool removeAllObjects];
195 | [_databaseInPool removeAllObjects];
196 | }];
197 | }
198 |
199 | - (void)inDatabase:(void (^)(FMDatabase *db))block {
200 |
201 | FMDatabase *db = [self db];
202 |
203 | block(db);
204 |
205 | [self pushDatabaseBackInPool:db];
206 | }
207 |
208 | - (void)beginTransaction:(BOOL)useDeferred withBlock:(void (^)(FMDatabase *db, BOOL *rollback))block {
209 |
210 | BOOL shouldRollback = NO;
211 |
212 | FMDatabase *db = [self db];
213 |
214 | if (useDeferred) {
215 | [db beginDeferredTransaction];
216 | }
217 | else {
218 | [db beginTransaction];
219 | }
220 |
221 |
222 | block(db, &shouldRollback);
223 |
224 | if (shouldRollback) {
225 | [db rollback];
226 | }
227 | else {
228 | [db commit];
229 | }
230 |
231 | [self pushDatabaseBackInPool:db];
232 | }
233 |
234 | - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
235 | [self beginTransaction:YES withBlock:block];
236 | }
237 |
238 | - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
239 | [self beginTransaction:NO withBlock:block];
240 | }
241 | #if SQLITE_VERSION_NUMBER >= 3007000
242 | - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
243 |
244 | static unsigned long savePointIdx = 0;
245 |
246 | NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++];
247 |
248 | BOOL shouldRollback = NO;
249 |
250 | FMDatabase *db = [self db];
251 |
252 | NSError *err = 0x00;
253 |
254 | if (![db startSavePointWithName:name error:&err]) {
255 | [self pushDatabaseBackInPool:db];
256 | return err;
257 | }
258 |
259 | block(db, &shouldRollback);
260 |
261 | if (shouldRollback) {
262 | // We need to rollback and release this savepoint to remove it
263 | [db rollbackToSavePointWithName:name error:&err];
264 | }
265 | [db releaseSavePointWithName:name error:&err];
266 |
267 | [self pushDatabaseBackInPool:db];
268 |
269 | return err;
270 | }
271 | #endif
272 |
273 | @end
274 |
--------------------------------------------------------------------------------
/Extension/NSString+YQ.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+PX.m
3 | // Paixin
4 | //
5 | // Created by Jasper on 14-3-4.
6 | // Copyright (c) 2014年 Jasper. All rights reserved.
7 | //
8 |
9 | #import "NSString+YQ.h"
10 | #include
11 | #import
12 |
13 | @implementation NSString (YQ)
14 |
15 | - (NSDictionary *)paramsFromURL {
16 | NSString *protocolString = @"";
17 | NSString *tmpString = @"";
18 | NSString *hostString = @"";
19 | NSString *uriString = @"/";
20 |
21 | if (NSNotFound != [self rangeOfString:@"://"].location) {
22 | protocolString = [self substringToIndex:([self rangeOfString:@"://"].location)];
23 | tmpString = [self substringFromIndex:([self rangeOfString:@"://"].location + 3)];
24 | }
25 |
26 | if (NSNotFound != [tmpString rangeOfString:@"/"].location) {
27 | hostString = [tmpString substringToIndex:([tmpString rangeOfString:@"/"].location)];
28 | tmpString = [self substringFromIndex:([self rangeOfString:hostString].location + [self rangeOfString:hostString].length)];
29 | }
30 | else if (NSNotFound != [tmpString rangeOfString:@"?"].location) {
31 | hostString = [tmpString substringToIndex:([tmpString rangeOfString:@"?"].location)];
32 | if (0 < hostString.length) {
33 | tmpString = [self substringFromIndex:([self rangeOfString:hostString].location + [self rangeOfString:hostString].length)];
34 | }
35 | }
36 | else {
37 | hostString = tmpString;
38 | tmpString = nil;
39 | }
40 |
41 | if (tmpString) {
42 | if (NSNotFound != [tmpString rangeOfString:@"/"].location) {
43 | if (NSNotFound != [tmpString rangeOfString:@"?"].location) {
44 | uriString = [tmpString substringToIndex:[tmpString rangeOfString:@"?"].location];
45 | }
46 | else {
47 | uriString = tmpString;
48 | }
49 | }
50 | }
51 | NSMutableDictionary* pairs = [NSMutableDictionary dictionary];
52 | if (NSNotFound != [self rangeOfString:@"?"].location) {
53 | NSString *paramString = [self substringFromIndex:([self rangeOfString:@"?"].location + 1)];
54 | NSCharacterSet* delimiterSet = [NSCharacterSet characterSetWithCharactersInString:@"&"];
55 | NSScanner* scanner = [[NSScanner alloc] initWithString:paramString];
56 | while (![scanner isAtEnd]) {
57 | NSString* pairString = nil;
58 | [scanner scanUpToCharactersFromSet:delimiterSet intoString:&pairString];
59 | [scanner scanCharactersFromSet:delimiterSet intoString:NULL];
60 | NSArray* kvPair = [pairString componentsSeparatedByString:@"="];
61 | if (kvPair.count == 2) {
62 | NSString* key = [[kvPair objectAtIndex:0] urldecode];
63 | NSString* value = [[kvPair objectAtIndex:1] urldecode];
64 | [pairs setObject:value forKey:key];
65 | }
66 | }
67 | }
68 | return [NSDictionary dictionaryWithObjectsAndKeys:
69 | pairs, PARAMS,
70 | protocolString, PROTOCOL,
71 | hostString, HOST,
72 | [uriString urldecode], PATH, nil];
73 | }
74 |
75 | - (NSString*)addUrlFromDictionary:(NSDictionary*)params {
76 | NSMutableString *_add = nil;
77 | if (NSNotFound != [self rangeOfString:@"?"].location) {
78 | _add = [NSMutableString stringWithString:@"&"];
79 | }else {
80 | _add = [NSMutableString stringWithString:@"?"];
81 | }
82 | for (NSString* key in [params allKeys]) {
83 | if ([params objectForKey:key] && 0 < [[params objectForKey:key] length]) {
84 | [_add appendFormat:@"%@=%@&",key,[[params objectForKey:key] urlencode]];
85 | }
86 | }
87 |
88 | return [NSString stringWithFormat:@"%@%@",self,[_add substringToIndex:[_add length] - 1]];
89 | }
90 |
91 | - (NSString *)urldecode {
92 | return [self stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
93 | }
94 |
95 | - (NSString *)urlencode {
96 | NSString *encUrl = [self stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
97 | int len = [encUrl length];
98 | const char *c;
99 | c = [encUrl UTF8String];
100 | NSString *ret = @"";
101 | for(int i = 0; i < len; i++) {
102 | switch (*c) {
103 | case '/':
104 | ret = [ret stringByAppendingString:@"%2F"];
105 | break;
106 | case '\'':
107 | ret = [ret stringByAppendingString:@"%27"];
108 | break;
109 | case ';':
110 | ret = [ret stringByAppendingString:@"%3B"];
111 | break;
112 | case '?':
113 | ret = [ret stringByAppendingString:@"%3F"];
114 | break;
115 | case ':':
116 | ret = [ret stringByAppendingString:@"%3A"];
117 | break;
118 | case '@':
119 | ret = [ret stringByAppendingString:@"%40"];
120 | break;
121 | case '&':
122 | ret = [ret stringByAppendingString:@"%26"];
123 | break;
124 | case '=':
125 | ret = [ret stringByAppendingString:@"%3D"];
126 | break;
127 | case '+':
128 | ret = [ret stringByAppendingString:@"%2B"];
129 | break;
130 | case '$':
131 | ret = [ret stringByAppendingString:@"%24"];
132 | break;
133 | case ',':
134 | ret = [ret stringByAppendingString:@"%2C"];
135 | break;
136 | case '[':
137 | ret = [ret stringByAppendingString:@"%5B"];
138 | break;
139 | case ']':
140 | ret = [ret stringByAppendingString:@"%5D"];
141 | break;
142 | case '#':
143 | ret = [ret stringByAppendingString:@"%23"];
144 | break;
145 | case '!':
146 | ret = [ret stringByAppendingString:@"%21"];
147 | break;
148 | case '(':
149 | ret = [ret stringByAppendingString:@"%28"];
150 | break;
151 | case ')':
152 | ret = [ret stringByAppendingString:@"%29"];
153 | break;
154 | case '*':
155 | ret = [ret stringByAppendingString:@"%2A"];
156 | break;
157 | default:
158 | ret = [ret stringByAppendingFormat:@"%c", *c];
159 | }
160 | c++;
161 | }
162 |
163 | return ret;
164 | }
165 |
166 | - (NSString *)MD5 {
167 | if(self == nil || [self length] == 0)
168 | return nil;
169 |
170 | const char* str = [self UTF8String];
171 | unsigned char result[CC_MD5_DIGEST_LENGTH];
172 | CC_MD5(str, strlen(str), result);
173 |
174 | NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2];
175 | for(int i = 0; i width) {
215 | break;
216 | }
217 | }
218 |
219 | return finalIndex;
220 | }
221 |
222 | // 将string分割为一个个字串,字母群为以一块,其他(汉字的单字为一块,符号为单字为一块,)
223 | - (NSArray *)arrayOfDividedIntoPiece {
224 | int currentBlockFromIndex = 0;
225 | int currentBlockToIndex = 0;
226 | int currentIndex = 0;
227 | int countAlpha = 0;
228 |
229 | // NSString *str = self;
230 | NSMutableArray *finalArray = [NSMutableArray array];
231 |
232 | int len = self.length;
233 | for (; currentIndex < len; currentIndex++) {
234 | int c = [self characterAtIndex:currentIndex];
235 |
236 | if (isalpha(c)) {
237 | if (countAlpha <= 0) {
238 | currentBlockToIndex = currentIndex;
239 | NSString *blockStr = [self substringWithRange:NSMakeRange(currentBlockFromIndex, currentBlockToIndex-currentBlockFromIndex)];
240 | if (blockStr && ![@"" isEqualToString:blockStr]) {
241 | [finalArray addObject:blockStr];
242 | }
243 | }
244 | countAlpha++;
245 | if (countAlpha == 1) {
246 | currentBlockFromIndex = currentIndex;
247 | }
248 | currentBlockToIndex = currentIndex + 1;
249 | } else {
250 | if (countAlpha > 0) {
251 | currentBlockToIndex = currentIndex;
252 |
253 | NSString *blockStr = [self substringWithRange:NSMakeRange(currentBlockFromIndex, currentBlockToIndex-currentBlockFromIndex)];
254 | if (blockStr && ![@"" isEqualToString:blockStr]) {
255 | [finalArray addObject:blockStr];
256 | }
257 |
258 | currentBlockFromIndex = currentIndex;
259 | currentBlockToIndex = currentIndex + 1;
260 | } else {
261 | currentBlockToIndex = currentIndex;
262 |
263 | NSString *blockStr = [self substringWithRange:NSMakeRange(currentBlockFromIndex, currentBlockToIndex-currentBlockFromIndex)];
264 | if (blockStr && ![@"" isEqualToString:blockStr]) {
265 | [finalArray addObject:blockStr];
266 | }
267 |
268 | currentBlockFromIndex = currentIndex;
269 | currentBlockToIndex = currentIndex + 1;
270 | }
271 |
272 | countAlpha = 0;
273 | }
274 | }
275 | // 将最后的子串也添加到数组中
276 | NSString *blockStr = [self substringWithRange:NSMakeRange(currentBlockFromIndex, currentBlockToIndex-currentBlockFromIndex)];
277 | if (blockStr && ![@"" isEqualToString:blockStr]) {
278 | [finalArray addObject:blockStr];
279 | }
280 |
281 | return finalArray;
282 | }
283 | // 截长子串(子串大于width宽度)为小子串
284 | - (NSArray *)arrayOfWidthFilted:(CGFloat)width font:(UIFont *)font fromArray:(NSArray *)array {
285 | NSMutableArray *finalArray = [NSMutableArray array];
286 | for (NSString *string in array) {
287 | if ([@"" isEqualToString:string]) {
288 | break;
289 | }
290 |
291 | NSString *str = string;
292 | while (true) {
293 | int rightIndex = [self indexOfRightWidth:width string:str font:font] + 1;
294 | [finalArray addObject:[str substringToIndex:rightIndex]];
295 | str = [str substringFromIndex:rightIndex];
296 |
297 | if (str && ![@"" isEqualToString:str]) {
298 | // CGSize testStrSize = [str sizeWithFont:font];
299 | //by jasper
300 |
301 | NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName,nil];
302 | CGSize testStrSize = [str boundingRectWithSize:testStrSize options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:tdic context:nil].size;
303 |
304 |
305 |
306 | if (testStrSize.width <= width) {
307 | [finalArray addObject:str];
308 | break;
309 | }
310 | } else break;
311 | }
312 |
313 | }
314 | return finalArray;
315 | }
316 |
317 | @end
318 |
319 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMResultSet.m:
--------------------------------------------------------------------------------
1 | #import "FMResultSet.h"
2 | #import "FMDatabase.h"
3 | #import "unistd.h"
4 |
5 | @interface FMDatabase ()
6 | - (void)resultSetDidClose:(FMResultSet *)resultSet;
7 | @end
8 |
9 |
10 | @implementation FMResultSet
11 | @synthesize query=_query;
12 | @synthesize statement=_statement;
13 |
14 | + (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB {
15 |
16 | FMResultSet *rs = [[FMResultSet alloc] init];
17 |
18 | [rs setStatement:statement];
19 | [rs setParentDB:aDB];
20 |
21 | NSParameterAssert(![statement inUse]);
22 | [statement setInUse:YES]; // weak reference
23 |
24 | return FMDBReturnAutoreleased(rs);
25 | }
26 |
27 | - (void)finalize {
28 | [self close];
29 | [super finalize];
30 | }
31 |
32 | - (void)dealloc {
33 | [self close];
34 |
35 | FMDBRelease(_query);
36 | _query = nil;
37 |
38 | FMDBRelease(_columnNameToIndexMap);
39 | _columnNameToIndexMap = nil;
40 |
41 | #if ! __has_feature(objc_arc)
42 | [super dealloc];
43 | #endif
44 | }
45 |
46 | - (void)close {
47 | [_statement reset];
48 | FMDBRelease(_statement);
49 | _statement = nil;
50 |
51 | // we don't need this anymore... (i think)
52 | //[_parentDB setInUse:NO];
53 | [_parentDB resultSetDidClose:self];
54 | _parentDB = nil;
55 | }
56 |
57 | - (int)columnCount {
58 | return sqlite3_column_count([_statement statement]);
59 | }
60 |
61 | - (NSMutableDictionary *)columnNameToIndexMap {
62 | if (!_columnNameToIndexMap) {
63 | int columnCount = sqlite3_column_count([_statement statement]);
64 | _columnNameToIndexMap = [[NSMutableDictionary alloc] initWithCapacity:(NSUInteger)columnCount];
65 | int columnIdx = 0;
66 | for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
67 | [_columnNameToIndexMap setObject:[NSNumber numberWithInt:columnIdx]
68 | forKey:[[NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)] lowercaseString]];
69 | }
70 | }
71 | return _columnNameToIndexMap;
72 | }
73 |
74 | - (void)kvcMagic:(id)object {
75 |
76 | int columnCount = sqlite3_column_count([_statement statement]);
77 |
78 | int columnIdx = 0;
79 | for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
80 |
81 | const char *c = (const char *)sqlite3_column_text([_statement statement], columnIdx);
82 |
83 | // check for a null row
84 | if (c) {
85 | NSString *s = [NSString stringWithUTF8String:c];
86 |
87 | [object setValue:s forKey:[NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)]];
88 | }
89 | }
90 | }
91 |
92 | #pragma clang diagnostic push
93 | #pragma clang diagnostic ignored "-Wdeprecated-implementations"
94 |
95 | - (NSDictionary*)resultDict {
96 |
97 | NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
98 |
99 | if (num_cols > 0) {
100 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
101 |
102 | NSEnumerator *columnNames = [[self columnNameToIndexMap] keyEnumerator];
103 | NSString *columnName = nil;
104 | while ((columnName = [columnNames nextObject])) {
105 | id objectValue = [self objectForColumnName:columnName];
106 | [dict setObject:objectValue forKey:columnName];
107 | }
108 |
109 | return FMDBReturnAutoreleased([dict copy]);
110 | }
111 | else {
112 | NSLog(@"Warning: There seem to be no columns in this set.");
113 | }
114 |
115 | return nil;
116 | }
117 |
118 | #pragma clang diagnostic pop
119 |
120 | - (NSDictionary*)resultDictionary {
121 |
122 | NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
123 |
124 | if (num_cols > 0) {
125 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
126 |
127 | int columnCount = sqlite3_column_count([_statement statement]);
128 |
129 | int columnIdx = 0;
130 | for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
131 |
132 | NSString *columnName = [NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)];
133 | id objectValue = [self objectForColumnIndex:columnIdx];
134 | [dict setObject:objectValue forKey:columnName];
135 | }
136 |
137 | return dict;
138 | }
139 | else {
140 | NSLog(@"Warning: There seem to be no columns in this set.");
141 | }
142 |
143 | return nil;
144 | }
145 |
146 |
147 |
148 |
149 | - (BOOL)next {
150 |
151 | int rc = sqlite3_step([_statement statement]);
152 |
153 | if (SQLITE_BUSY == rc || SQLITE_LOCKED == rc) {
154 | NSLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [_parentDB databasePath]);
155 | NSLog(@"Database busy");
156 | }
157 | else if (SQLITE_DONE == rc || SQLITE_ROW == rc) {
158 | // all is well, let's return.
159 | }
160 | else if (SQLITE_ERROR == rc) {
161 | NSLog(@"Error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
162 | }
163 | else if (SQLITE_MISUSE == rc) {
164 | // uh oh.
165 | NSLog(@"Error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
166 | }
167 | else {
168 | // wtf?
169 | NSLog(@"Unknown error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
170 | }
171 |
172 |
173 | if (rc != SQLITE_ROW) {
174 | [self close];
175 | }
176 |
177 | return (rc == SQLITE_ROW);
178 | }
179 |
180 | - (BOOL)hasAnotherRow {
181 | return sqlite3_errcode([_parentDB sqliteHandle]) == SQLITE_ROW;
182 | }
183 |
184 | - (int)columnIndexForName:(NSString*)columnName {
185 | columnName = [columnName lowercaseString];
186 |
187 | NSNumber *n = [[self columnNameToIndexMap] objectForKey:columnName];
188 |
189 | if (n) {
190 | return [n intValue];
191 | }
192 |
193 | NSLog(@"Warning: I could not find the column named '%@'.", columnName);
194 |
195 | return -1;
196 | }
197 |
198 |
199 |
200 | - (int)intForColumn:(NSString*)columnName {
201 | return [self intForColumnIndex:[self columnIndexForName:columnName]];
202 | }
203 |
204 | - (int)intForColumnIndex:(int)columnIdx {
205 | return sqlite3_column_int([_statement statement], columnIdx);
206 | }
207 |
208 | - (long)longForColumn:(NSString*)columnName {
209 | return [self longForColumnIndex:[self columnIndexForName:columnName]];
210 | }
211 |
212 | - (long)longForColumnIndex:(int)columnIdx {
213 | return (long)sqlite3_column_int64([_statement statement], columnIdx);
214 | }
215 |
216 | - (long long int)longLongIntForColumn:(NSString*)columnName {
217 | return [self longLongIntForColumnIndex:[self columnIndexForName:columnName]];
218 | }
219 |
220 | - (long long int)longLongIntForColumnIndex:(int)columnIdx {
221 | return sqlite3_column_int64([_statement statement], columnIdx);
222 | }
223 |
224 | - (unsigned long long int)unsignedLongLongIntForColumn:(NSString*)columnName {
225 | return [self unsignedLongLongIntForColumnIndex:[self columnIndexForName:columnName]];
226 | }
227 |
228 | - (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx {
229 | return (unsigned long long int)[self longLongIntForColumnIndex:columnIdx];
230 | }
231 |
232 | - (BOOL)boolForColumn:(NSString*)columnName {
233 | return [self boolForColumnIndex:[self columnIndexForName:columnName]];
234 | }
235 |
236 | - (BOOL)boolForColumnIndex:(int)columnIdx {
237 | return ([self intForColumnIndex:columnIdx] != 0);
238 | }
239 |
240 | - (double)doubleForColumn:(NSString*)columnName {
241 | return [self doubleForColumnIndex:[self columnIndexForName:columnName]];
242 | }
243 |
244 | - (double)doubleForColumnIndex:(int)columnIdx {
245 | return sqlite3_column_double([_statement statement], columnIdx);
246 | }
247 |
248 | - (NSString*)stringForColumnIndex:(int)columnIdx {
249 |
250 | if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
251 | return nil;
252 | }
253 |
254 | const char *c = (const char *)sqlite3_column_text([_statement statement], columnIdx);
255 |
256 | if (!c) {
257 | // null row.
258 | return nil;
259 | }
260 |
261 | return [NSString stringWithUTF8String:c];
262 | }
263 |
264 | - (NSString*)stringForColumn:(NSString*)columnName {
265 | return [self stringForColumnIndex:[self columnIndexForName:columnName]];
266 | }
267 |
268 | - (NSDate*)dateForColumn:(NSString*)columnName {
269 | return [self dateForColumnIndex:[self columnIndexForName:columnName]];
270 | }
271 |
272 | - (NSDate*)dateForColumnIndex:(int)columnIdx {
273 |
274 | if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
275 | return nil;
276 | }
277 |
278 | return [_parentDB hasDateFormatter] ? [_parentDB dateFromString:[self stringForColumnIndex:columnIdx]] : [NSDate dateWithTimeIntervalSince1970:[self doubleForColumnIndex:columnIdx]];
279 | }
280 |
281 |
282 | - (NSData*)dataForColumn:(NSString*)columnName {
283 | return [self dataForColumnIndex:[self columnIndexForName:columnName]];
284 | }
285 |
286 | - (NSData*)dataForColumnIndex:(int)columnIdx {
287 |
288 | if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
289 | return nil;
290 | }
291 |
292 | int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
293 |
294 | NSMutableData *data = [NSMutableData dataWithLength:(NSUInteger)dataSize];
295 |
296 | memcpy([data mutableBytes], sqlite3_column_blob([_statement statement], columnIdx), dataSize);
297 |
298 | return data;
299 | }
300 |
301 |
302 | - (NSData*)dataNoCopyForColumn:(NSString*)columnName {
303 | return [self dataNoCopyForColumnIndex:[self columnIndexForName:columnName]];
304 | }
305 |
306 | - (NSData*)dataNoCopyForColumnIndex:(int)columnIdx {
307 |
308 | if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
309 | return nil;
310 | }
311 |
312 | int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
313 |
314 | NSData *data = [NSData dataWithBytesNoCopy:(void *)sqlite3_column_blob([_statement statement], columnIdx) length:(NSUInteger)dataSize freeWhenDone:NO];
315 |
316 | return data;
317 | }
318 |
319 |
320 | - (BOOL)columnIndexIsNull:(int)columnIdx {
321 | return sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL;
322 | }
323 |
324 | - (BOOL)columnIsNull:(NSString*)columnName {
325 | return [self columnIndexIsNull:[self columnIndexForName:columnName]];
326 | }
327 |
328 | - (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx {
329 |
330 | if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
331 | return nil;
332 | }
333 |
334 | return sqlite3_column_text([_statement statement], columnIdx);
335 | }
336 |
337 | - (const unsigned char *)UTF8StringForColumnName:(NSString*)columnName {
338 | return [self UTF8StringForColumnIndex:[self columnIndexForName:columnName]];
339 | }
340 |
341 | - (id)objectForColumnIndex:(int)columnIdx {
342 | int columnType = sqlite3_column_type([_statement statement], columnIdx);
343 |
344 | id returnValue = nil;
345 |
346 | if (columnType == SQLITE_INTEGER) {
347 | returnValue = [NSNumber numberWithLongLong:[self longLongIntForColumnIndex:columnIdx]];
348 | }
349 | else if (columnType == SQLITE_FLOAT) {
350 | returnValue = [NSNumber numberWithDouble:[self doubleForColumnIndex:columnIdx]];
351 | }
352 | else if (columnType == SQLITE_BLOB) {
353 | returnValue = [self dataForColumnIndex:columnIdx];
354 | }
355 | else {
356 | //default to a string for everything else
357 | returnValue = [self stringForColumnIndex:columnIdx];
358 | }
359 |
360 | if (returnValue == nil) {
361 | returnValue = [NSNull null];
362 | }
363 |
364 | return returnValue;
365 | }
366 |
367 | - (id)objectForColumnName:(NSString*)columnName {
368 | return [self objectForColumnIndex:[self columnIndexForName:columnName]];
369 | }
370 |
371 | // returns autoreleased NSString containing the name of the column in the result set
372 | - (NSString*)columnNameForIndex:(int)columnIdx {
373 | return [NSString stringWithUTF8String: sqlite3_column_name([_statement statement], columnIdx)];
374 | }
375 |
376 | - (void)setParentDB:(FMDatabase *)newDb {
377 | _parentDB = newDb;
378 | }
379 |
380 | - (id)objectAtIndexedSubscript:(int)columnIdx {
381 | return [self objectForColumnIndex:columnIdx];
382 | }
383 |
384 | - (id)objectForKeyedSubscript:(NSString *)columnName {
385 | return [self objectForColumnName:columnName];
386 | }
387 |
388 |
389 | @end
390 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMResultSet.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "sqlite3.h"
3 |
4 | #ifndef __has_feature // Optional.
5 | #define __has_feature(x) 0 // Compatibility with non-clang compilers.
6 | #endif
7 |
8 | #ifndef NS_RETURNS_NOT_RETAINED
9 | #if __has_feature(attribute_ns_returns_not_retained)
10 | #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
11 | #else
12 | #define NS_RETURNS_NOT_RETAINED
13 | #endif
14 | #endif
15 |
16 | @class FMDatabase;
17 | @class FMStatement;
18 |
19 | /** Represents the results of executing a query on an ``.
20 |
21 | ### See also
22 |
23 | - ``
24 | */
25 |
26 | @interface FMResultSet : NSObject {
27 | FMDatabase *_parentDB;
28 | FMStatement *_statement;
29 |
30 | NSString *_query;
31 | NSMutableDictionary *_columnNameToIndexMap;
32 | }
33 |
34 | ///-----------------
35 | /// @name Properties
36 | ///-----------------
37 |
38 | /** Executed query */
39 |
40 | @property (atomic, retain) NSString *query;
41 |
42 | /** `NSMutableDictionary` mapping column names to numeric index */
43 |
44 | @property (readonly) NSMutableDictionary *columnNameToIndexMap;
45 |
46 | /** `FMStatement` used by result set. */
47 |
48 | @property (atomic, retain) FMStatement *statement;
49 |
50 | ///------------------------------------
51 | /// @name Creating and closing database
52 | ///------------------------------------
53 |
54 | /** Create result set from ``
55 |
56 | @param statement A `` to be performed
57 |
58 | @param aDB A `` to be used
59 |
60 | @return A `FMResultSet` on success; `nil` on failure
61 | */
62 |
63 | + (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB;
64 |
65 | /** Close result set */
66 |
67 | - (void)close;
68 |
69 | - (void)setParentDB:(FMDatabase *)newDb;
70 |
71 | ///---------------------------------------
72 | /// @name Iterating through the result set
73 | ///---------------------------------------
74 |
75 | /** Retrieve next row for result set.
76 |
77 | You must always invoke `next` before attempting to access the values returned in a query, even if you're only expecting one.
78 |
79 | @return `YES` if row successfully retrieved; `NO` if end of result set reached
80 |
81 | @see hasAnotherRow
82 | */
83 |
84 | - (BOOL)next;
85 |
86 | /** Did the last call to `` succeed in retrieving another row?
87 |
88 | @return `YES` if the last call to `` succeeded in retrieving another record; `NO` if not.
89 |
90 | @see next
91 |
92 | @warning The `hasAnotherRow` method must follow a call to ``. If the previous database interaction was something other than a call to `next`, then this method may return `NO`, whether there is another row of data or not.
93 | */
94 |
95 | - (BOOL)hasAnotherRow;
96 |
97 | ///---------------------------------------------
98 | /// @name Retrieving information from result set
99 | ///---------------------------------------------
100 |
101 | /** How many columns in result set
102 |
103 | @return Integer value of the number of columns.
104 | */
105 |
106 | - (int)columnCount;
107 |
108 | /** Column index for column name
109 |
110 | @param columnName `NSString` value of the name of the column.
111 |
112 | @return Zero-based index for column.
113 | */
114 |
115 | - (int)columnIndexForName:(NSString*)columnName;
116 |
117 | /** Column name for column index
118 |
119 | @param columnIdx Zero-based index for column.
120 |
121 | @return columnName `NSString` value of the name of the column.
122 | */
123 |
124 | - (NSString*)columnNameForIndex:(int)columnIdx;
125 |
126 | /** Result set integer value for column.
127 |
128 | @param columnName `NSString` value of the name of the column.
129 |
130 | @return `int` value of the result set's column.
131 | */
132 |
133 | - (int)intForColumn:(NSString*)columnName;
134 |
135 | /** Result set integer value for column.
136 |
137 | @param columnIdx Zero-based index for column.
138 |
139 | @return `int` value of the result set's column.
140 | */
141 |
142 | - (int)intForColumnIndex:(int)columnIdx;
143 |
144 | /** Result set `long` value for column.
145 |
146 | @param columnName `NSString` value of the name of the column.
147 |
148 | @return `long` value of the result set's column.
149 | */
150 |
151 | - (long)longForColumn:(NSString*)columnName;
152 |
153 | /** Result set long value for column.
154 |
155 | @param columnIdx Zero-based index for column.
156 |
157 | @return `long` value of the result set's column.
158 | */
159 |
160 | - (long)longForColumnIndex:(int)columnIdx;
161 |
162 | /** Result set `long long int` value for column.
163 |
164 | @param columnName `NSString` value of the name of the column.
165 |
166 | @return `long long int` value of the result set's column.
167 | */
168 |
169 | - (long long int)longLongIntForColumn:(NSString*)columnName;
170 |
171 | /** Result set `long long int` value for column.
172 |
173 | @param columnIdx Zero-based index for column.
174 |
175 | @return `long long int` value of the result set's column.
176 | */
177 |
178 | - (long long int)longLongIntForColumnIndex:(int)columnIdx;
179 |
180 | /** Result set `unsigned long long int` value for column.
181 |
182 | @param columnName `NSString` value of the name of the column.
183 |
184 | @return `unsigned long long int` value of the result set's column.
185 | */
186 |
187 | - (unsigned long long int)unsignedLongLongIntForColumn:(NSString*)columnName;
188 |
189 | /** Result set `unsigned long long int` value for column.
190 |
191 | @param columnIdx Zero-based index for column.
192 |
193 | @return `unsigned long long int` value of the result set's column.
194 | */
195 |
196 | - (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx;
197 |
198 | /** Result set `BOOL` value for column.
199 |
200 | @param columnName `NSString` value of the name of the column.
201 |
202 | @return `BOOL` value of the result set's column.
203 | */
204 |
205 | - (BOOL)boolForColumn:(NSString*)columnName;
206 |
207 | /** Result set `BOOL` value for column.
208 |
209 | @param columnIdx Zero-based index for column.
210 |
211 | @return `BOOL` value of the result set's column.
212 | */
213 |
214 | - (BOOL)boolForColumnIndex:(int)columnIdx;
215 |
216 | /** Result set `double` value for column.
217 |
218 | @param columnName `NSString` value of the name of the column.
219 |
220 | @return `double` value of the result set's column.
221 |
222 | */
223 |
224 | - (double)doubleForColumn:(NSString*)columnName;
225 |
226 | /** Result set `double` value for column.
227 |
228 | @param columnIdx Zero-based index for column.
229 |
230 | @return `double` value of the result set's column.
231 |
232 | */
233 |
234 | - (double)doubleForColumnIndex:(int)columnIdx;
235 |
236 | /** Result set `NSString` value for column.
237 |
238 | @param columnName `NSString` value of the name of the column.
239 |
240 | @return `NSString` value of the result set's column.
241 |
242 | */
243 |
244 | - (NSString*)stringForColumn:(NSString*)columnName;
245 |
246 | /** Result set `NSString` value for column.
247 |
248 | @param columnIdx Zero-based index for column.
249 |
250 | @return `NSString` value of the result set's column.
251 | */
252 |
253 | - (NSString*)stringForColumnIndex:(int)columnIdx;
254 |
255 | /** Result set `NSDate` value for column.
256 |
257 | @param columnName `NSString` value of the name of the column.
258 |
259 | @return `NSDate` value of the result set's column.
260 | */
261 |
262 | - (NSDate*)dateForColumn:(NSString*)columnName;
263 |
264 | /** Result set `NSDate` value for column.
265 |
266 | @param columnIdx Zero-based index for column.
267 |
268 | @return `NSDate` value of the result set's column.
269 |
270 | */
271 |
272 | - (NSDate*)dateForColumnIndex:(int)columnIdx;
273 |
274 | /** Result set `NSData` value for column.
275 |
276 | This is useful when storing binary data in table (such as image or the like).
277 |
278 | @param columnName `NSString` value of the name of the column.
279 |
280 | @return `NSData` value of the result set's column.
281 |
282 | */
283 |
284 | - (NSData*)dataForColumn:(NSString*)columnName;
285 |
286 | /** Result set `NSData` value for column.
287 |
288 | @param columnIdx Zero-based index for column.
289 |
290 | @return `NSData` value of the result set's column.
291 | */
292 |
293 | - (NSData*)dataForColumnIndex:(int)columnIdx;
294 |
295 | /** Result set `(const unsigned char *)` value for column.
296 |
297 | @param columnName `NSString` value of the name of the column.
298 |
299 | @return `(const unsigned char *)` value of the result set's column.
300 | */
301 |
302 | - (const unsigned char *)UTF8StringForColumnName:(NSString*)columnName;
303 |
304 | /** Result set `(const unsigned char *)` value for column.
305 |
306 | @param columnIdx Zero-based index for column.
307 |
308 | @return `(const unsigned char *)` value of the result set's column.
309 | */
310 |
311 | - (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx;
312 |
313 | /** Result set object for column.
314 |
315 | @param columnName `NSString` value of the name of the column.
316 |
317 | @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
318 |
319 | @see objectForKeyedSubscript:
320 | */
321 |
322 | - (id)objectForColumnName:(NSString*)columnName;
323 |
324 | /** Result set object for column.
325 |
326 | @param columnIdx Zero-based index for column.
327 |
328 | @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
329 |
330 | @see objectAtIndexedSubscript:
331 | */
332 |
333 | - (id)objectForColumnIndex:(int)columnIdx;
334 |
335 | /** Result set object for column.
336 |
337 | This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
338 |
339 | id result = rs[@"employee_name"];
340 |
341 | This simplified syntax is equivalent to calling:
342 |
343 | id result = [rs objectForKeyedSubscript:@"employee_name"];
344 |
345 | which is, it turns out, equivalent to calling:
346 |
347 | id result = [rs objectForColumnName:@"employee_name"];
348 |
349 | @param columnName `NSString` value of the name of the column.
350 |
351 | @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
352 | */
353 |
354 | - (id)objectForKeyedSubscript:(NSString *)columnName;
355 |
356 | /** Result set object for column.
357 |
358 | This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
359 |
360 | id result = rs[0];
361 |
362 | This simplified syntax is equivalent to calling:
363 |
364 | id result = [rs objectForKeyedSubscript:0];
365 |
366 | which is, it turns out, equivalent to calling:
367 |
368 | id result = [rs objectForColumnName:0];
369 |
370 | @param columnIdx Zero-based index for column.
371 |
372 | @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
373 | */
374 |
375 | - (id)objectAtIndexedSubscript:(int)columnIdx;
376 |
377 | /** Result set `NSData` value for column.
378 |
379 | @param columnName `NSString` value of the name of the column.
380 |
381 | @return `NSData` value of the result set's column.
382 |
383 | @warning If you are going to use this data after you iterate over the next row, or after you close the
384 | result set, make sure to make a copy of the data first (or just use ``/``)
385 | If you don't, you're going to be in a world of hurt when you try and use the data.
386 |
387 | */
388 |
389 | - (NSData*)dataNoCopyForColumn:(NSString*)columnName NS_RETURNS_NOT_RETAINED;
390 |
391 | /** Result set `NSData` value for column.
392 |
393 | @param columnIdx Zero-based index for column.
394 |
395 | @return `NSData` value of the result set's column.
396 |
397 | @warning If you are going to use this data after you iterate over the next row, or after you close the
398 | result set, make sure to make a copy of the data first (or just use ``/``)
399 | If you don't, you're going to be in a world of hurt when you try and use the data.
400 |
401 | */
402 |
403 | - (NSData*)dataNoCopyForColumnIndex:(int)columnIdx NS_RETURNS_NOT_RETAINED;
404 |
405 | /** Is the column `NULL`?
406 |
407 | @param columnIdx Zero-based index for column.
408 |
409 | @return `YES` if column is `NULL`; `NO` if not `NULL`.
410 | */
411 |
412 | - (BOOL)columnIndexIsNull:(int)columnIdx;
413 |
414 | /** Is the column `NULL`?
415 |
416 | @param columnName `NSString` value of the name of the column.
417 |
418 | @return `YES` if column is `NULL`; `NO` if not `NULL`.
419 | */
420 |
421 | - (BOOL)columnIsNull:(NSString*)columnName;
422 |
423 |
424 | /** Returns a dictionary of the row results mapped to case sensitive keys of the column names.
425 |
426 | @returns `NSDictionary` of the row results.
427 |
428 | @warning The keys to the dictionary are case sensitive of the column names.
429 | */
430 |
431 | - (NSDictionary*)resultDictionary;
432 |
433 | /** Returns a dictionary of the row results
434 |
435 | @see resultDictionary
436 |
437 | @warning **Deprecated**: Please use `` instead. Also, beware that `` is case sensitive!
438 | */
439 |
440 | - (NSDictionary*)resultDict __attribute__ ((deprecated));
441 |
442 | ///-----------------------------
443 | /// @name Key value coding magic
444 | ///-----------------------------
445 |
446 | /** Performs `setValue` to yield support for key value observing.
447 |
448 | @param object The object for which the values will be set. This is the key-value-coding compliant object that you might, for example, observe.
449 |
450 | */
451 |
452 | - (void)kvcMagic:(id)object;
453 |
454 |
455 | @end
456 |
457 |
--------------------------------------------------------------------------------
/URLNavigation.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | A4C0E77C197CB2FD005DDFD0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E77B197CB2FD005DDFD0 /* Foundation.framework */; };
11 | A4C0E77E197CB2FD005DDFD0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E77D197CB2FD005DDFD0 /* CoreGraphics.framework */; };
12 | A4C0E780197CB2FE005DDFD0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E77F197CB2FE005DDFD0 /* UIKit.framework */; };
13 | A4C0E786197CB2FE005DDFD0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A4C0E784197CB2FE005DDFD0 /* InfoPlist.strings */; };
14 | A4C0E788197CB2FE005DDFD0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E787197CB2FE005DDFD0 /* main.m */; };
15 | A4C0E78C197CB2FE005DDFD0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E78B197CB2FE005DDFD0 /* AppDelegate.m */; };
16 | A4C0E794197CB2FE005DDFD0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A4C0E793197CB2FE005DDFD0 /* Images.xcassets */; };
17 | A4C0E79B197CB2FE005DDFD0 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E79A197CB2FE005DDFD0 /* XCTest.framework */; };
18 | A4C0E79C197CB2FE005DDFD0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E77B197CB2FD005DDFD0 /* Foundation.framework */; };
19 | A4C0E79D197CB2FE005DDFD0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C0E77F197CB2FE005DDFD0 /* UIKit.framework */; };
20 | A4C0E7A5197CB2FE005DDFD0 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A4C0E7A3197CB2FE005DDFD0 /* InfoPlist.strings */; };
21 | A4C0E7A7197CB2FE005DDFD0 /* URLNavigationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7A6197CB2FE005DDFD0 /* URLNavigationTests.m */; };
22 | A4C0E7B2197CB333005DDFD0 /* YQBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7B1197CB333005DDFD0 /* YQBaseViewController.m */; };
23 | A4C0E7B5197CB367005DDFD0 /* YQNavigationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7B4197CB367005DDFD0 /* YQNavigationViewController.m */; };
24 | A4C0E7BC197CB439005DDFD0 /* NSString+YQ.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7BB197CB439005DDFD0 /* NSString+YQ.m */; };
25 | A4C0E7BF197CB496005DDFD0 /* YQNavigator.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7BE197CB496005DDFD0 /* YQNavigator.m */; };
26 | A4C0E7C2197CB599005DDFD0 /* AViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7C1197CB599005DDFD0 /* AViewController.m */; };
27 | A4C0E7C5197CB5A5005DDFD0 /* BViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7C4197CB5A5005DDFD0 /* BViewController.m */; };
28 | A4C0E7C8197CB5B0005DDFD0 /* CViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7C7197CB5B0005DDFD0 /* CViewController.m */; };
29 | A4C0E7CB197CB5BC005DDFD0 /* DViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7CA197CB5BC005DDFD0 /* DViewController.m */; };
30 | A4C0E7CE197CB5C7005DDFD0 /* EViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C0E7CD197CB5C7005DDFD0 /* EViewController.m */; };
31 | A4C49CE0197DFE7A007C860C /* Sample.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CDF197DFE7A007C860C /* Sample.m */; };
32 | A4C49CF4197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CE7197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.m */; };
33 | A4C49CF5197DFF30007C860C /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CEA197DFF30007C860C /* FMDatabase.m */; };
34 | A4C49CF6197DFF30007C860C /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CEC197DFF30007C860C /* FMDatabaseAdditions.m */; };
35 | A4C49CF7197DFF30007C860C /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CEE197DFF30007C860C /* FMDatabasePool.m */; };
36 | A4C49CF8197DFF30007C860C /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CF0197DFF30007C860C /* FMDatabaseQueue.m */; };
37 | A4C49CF9197DFF30007C860C /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CF3197DFF30007C860C /* FMResultSet.m */; };
38 | A4C49CFC197DFF58007C860C /* YQDBCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CFB197DFF58007C860C /* YQDBCenter.m */; };
39 | A4C49CFF197DFF69007C860C /* YQCacheCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = A4C49CFE197DFF69007C860C /* YQCacheCenter.m */; };
40 | A4C49D01197E0115007C860C /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A4C49D00197E0115007C860C /* libsqlite3.dylib */; };
41 | /* End PBXBuildFile section */
42 |
43 | /* Begin PBXContainerItemProxy section */
44 | A4C0E79E197CB2FE005DDFD0 /* PBXContainerItemProxy */ = {
45 | isa = PBXContainerItemProxy;
46 | containerPortal = A4C0E770197CB2FD005DDFD0 /* Project object */;
47 | proxyType = 1;
48 | remoteGlobalIDString = A4C0E777197CB2FD005DDFD0;
49 | remoteInfo = URLNavigation;
50 | };
51 | /* End PBXContainerItemProxy section */
52 |
53 | /* Begin PBXFileReference section */
54 | A4C0E778197CB2FD005DDFD0 /* URLNavigation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = URLNavigation.app; sourceTree = BUILT_PRODUCTS_DIR; };
55 | A4C0E77B197CB2FD005DDFD0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
56 | A4C0E77D197CB2FD005DDFD0 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
57 | A4C0E77F197CB2FE005DDFD0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
58 | A4C0E783197CB2FE005DDFD0 /* URLNavigation-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "URLNavigation-Info.plist"; sourceTree = ""; };
59 | A4C0E785197CB2FE005DDFD0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
60 | A4C0E787197CB2FE005DDFD0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
61 | A4C0E789197CB2FE005DDFD0 /* URLNavigation-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "URLNavigation-Prefix.pch"; sourceTree = ""; };
62 | A4C0E78A197CB2FE005DDFD0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
63 | A4C0E78B197CB2FE005DDFD0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
64 | A4C0E793197CB2FE005DDFD0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
65 | A4C0E799197CB2FE005DDFD0 /* URLNavigationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = URLNavigationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
66 | A4C0E79A197CB2FE005DDFD0 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
67 | A4C0E7A2197CB2FE005DDFD0 /* URLNavigationTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "URLNavigationTests-Info.plist"; sourceTree = ""; };
68 | A4C0E7A4197CB2FE005DDFD0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
69 | A4C0E7A6197CB2FE005DDFD0 /* URLNavigationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLNavigationTests.m; sourceTree = ""; };
70 | A4C0E7B0197CB333005DDFD0 /* YQBaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQBaseViewController.h; sourceTree = ""; };
71 | A4C0E7B1197CB333005DDFD0 /* YQBaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQBaseViewController.m; sourceTree = ""; };
72 | A4C0E7B3197CB367005DDFD0 /* YQNavigationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQNavigationViewController.h; sourceTree = ""; };
73 | A4C0E7B4197CB367005DDFD0 /* YQNavigationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQNavigationViewController.m; sourceTree = ""; };
74 | A4C0E7BA197CB439005DDFD0 /* NSString+YQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+YQ.h"; sourceTree = ""; };
75 | A4C0E7BB197CB439005DDFD0 /* NSString+YQ.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+YQ.m"; sourceTree = ""; };
76 | A4C0E7BD197CB496005DDFD0 /* YQNavigator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQNavigator.h; sourceTree = ""; };
77 | A4C0E7BE197CB496005DDFD0 /* YQNavigator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQNavigator.m; sourceTree = ""; };
78 | A4C0E7C0197CB599005DDFD0 /* AViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AViewController.h; sourceTree = ""; };
79 | A4C0E7C1197CB599005DDFD0 /* AViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AViewController.m; sourceTree = ""; };
80 | A4C0E7C3197CB5A5005DDFD0 /* BViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BViewController.h; sourceTree = ""; };
81 | A4C0E7C4197CB5A5005DDFD0 /* BViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BViewController.m; sourceTree = ""; };
82 | A4C0E7C6197CB5B0005DDFD0 /* CViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CViewController.h; sourceTree = ""; };
83 | A4C0E7C7197CB5B0005DDFD0 /* CViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CViewController.m; sourceTree = ""; };
84 | A4C0E7C9197CB5BC005DDFD0 /* DViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DViewController.h; sourceTree = ""; };
85 | A4C0E7CA197CB5BC005DDFD0 /* DViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DViewController.m; sourceTree = ""; };
86 | A4C0E7CC197CB5C7005DDFD0 /* EViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EViewController.h; sourceTree = ""; };
87 | A4C0E7CD197CB5C7005DDFD0 /* EViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EViewController.m; sourceTree = ""; };
88 | A4C0E7CF197CB94E005DDFD0 /* YQDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YQDefine.h; sourceTree = ""; };
89 | A4C0E7D0197CBAAD005DDFD0 /* ViewControllers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewControllers.h; sourceTree = ""; };
90 | A4C49CDE197DFE7A007C860C /* Sample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sample.h; sourceTree = ""; };
91 | A4C49CDF197DFE7A007C860C /* Sample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Sample.m; sourceTree = ""; };
92 | A4C49CE6197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FMDatabase+InMemoryOnDiskIO.h"; sourceTree = ""; };
93 | A4C49CE7197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "FMDatabase+InMemoryOnDiskIO.m"; sourceTree = ""; };
94 | A4C49CE9197DFF30007C860C /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = ""; };
95 | A4C49CEA197DFF30007C860C /* FMDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabase.m; sourceTree = ""; };
96 | A4C49CEB197DFF30007C860C /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseAdditions.h; sourceTree = ""; };
97 | A4C49CEC197DFF30007C860C /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseAdditions.m; sourceTree = ""; };
98 | A4C49CED197DFF30007C860C /* FMDatabasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabasePool.h; sourceTree = ""; };
99 | A4C49CEE197DFF30007C860C /* FMDatabasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabasePool.m; sourceTree = ""; };
100 | A4C49CEF197DFF30007C860C /* FMDatabaseQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseQueue.h; sourceTree = ""; };
101 | A4C49CF0197DFF30007C860C /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = ""; };
102 | A4C49CF1197DFF30007C860C /* FMDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDB.h; sourceTree = ""; };
103 | A4C49CF2197DFF30007C860C /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = ""; };
104 | A4C49CF3197DFF30007C860C /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = ""; };
105 | A4C49CFA197DFF58007C860C /* YQDBCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQDBCenter.h; sourceTree = ""; };
106 | A4C49CFB197DFF58007C860C /* YQDBCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQDBCenter.m; sourceTree = ""; };
107 | A4C49CFD197DFF69007C860C /* YQCacheCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YQCacheCenter.h; sourceTree = ""; };
108 | A4C49CFE197DFF69007C860C /* YQCacheCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YQCacheCenter.m; sourceTree = ""; };
109 | A4C49D00197E0115007C860C /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
110 | /* End PBXFileReference section */
111 |
112 | /* Begin PBXFrameworksBuildPhase section */
113 | A4C0E775197CB2FD005DDFD0 /* Frameworks */ = {
114 | isa = PBXFrameworksBuildPhase;
115 | buildActionMask = 2147483647;
116 | files = (
117 | A4C49D01197E0115007C860C /* libsqlite3.dylib in Frameworks */,
118 | A4C0E77E197CB2FD005DDFD0 /* CoreGraphics.framework in Frameworks */,
119 | A4C0E780197CB2FE005DDFD0 /* UIKit.framework in Frameworks */,
120 | A4C0E77C197CB2FD005DDFD0 /* Foundation.framework in Frameworks */,
121 | );
122 | runOnlyForDeploymentPostprocessing = 0;
123 | };
124 | A4C0E796197CB2FE005DDFD0 /* Frameworks */ = {
125 | isa = PBXFrameworksBuildPhase;
126 | buildActionMask = 2147483647;
127 | files = (
128 | A4C0E79B197CB2FE005DDFD0 /* XCTest.framework in Frameworks */,
129 | A4C0E79D197CB2FE005DDFD0 /* UIKit.framework in Frameworks */,
130 | A4C0E79C197CB2FE005DDFD0 /* Foundation.framework in Frameworks */,
131 | );
132 | runOnlyForDeploymentPostprocessing = 0;
133 | };
134 | /* End PBXFrameworksBuildPhase section */
135 |
136 | /* Begin PBXGroup section */
137 | A4C0E76F197CB2FD005DDFD0 = {
138 | isa = PBXGroup;
139 | children = (
140 | A4C0E781197CB2FE005DDFD0 /* URLNavigation */,
141 | A4C0E7A0197CB2FE005DDFD0 /* URLNavigationTests */,
142 | A4C0E77A197CB2FD005DDFD0 /* Frameworks */,
143 | A4C0E779197CB2FD005DDFD0 /* Products */,
144 | );
145 | sourceTree = "";
146 | };
147 | A4C0E779197CB2FD005DDFD0 /* Products */ = {
148 | isa = PBXGroup;
149 | children = (
150 | A4C0E778197CB2FD005DDFD0 /* URLNavigation.app */,
151 | A4C0E799197CB2FE005DDFD0 /* URLNavigationTests.xctest */,
152 | );
153 | name = Products;
154 | sourceTree = "";
155 | };
156 | A4C0E77A197CB2FD005DDFD0 /* Frameworks */ = {
157 | isa = PBXGroup;
158 | children = (
159 | A4C49D00197E0115007C860C /* libsqlite3.dylib */,
160 | A4C0E77B197CB2FD005DDFD0 /* Foundation.framework */,
161 | A4C0E77D197CB2FD005DDFD0 /* CoreGraphics.framework */,
162 | A4C0E77F197CB2FE005DDFD0 /* UIKit.framework */,
163 | A4C0E79A197CB2FE005DDFD0 /* XCTest.framework */,
164 | );
165 | name = Frameworks;
166 | sourceTree = "";
167 | };
168 | A4C0E781197CB2FE005DDFD0 /* URLNavigation */ = {
169 | isa = PBXGroup;
170 | children = (
171 | A4C0E78A197CB2FE005DDFD0 /* AppDelegate.h */,
172 | A4C0E78B197CB2FE005DDFD0 /* AppDelegate.m */,
173 | A4C0E7BD197CB496005DDFD0 /* YQNavigator.h */,
174 | A4C0E7BE197CB496005DDFD0 /* YQNavigator.m */,
175 | A4C0E7CF197CB94E005DDFD0 /* YQDefine.h */,
176 | A4C0E7B9197CB439005DDFD0 /* Extension */,
177 | A4C0E7B6197CB3D9005DDFD0 /* Controller */,
178 | A4C0E7D1197CC199005DDFD0 /* Model */,
179 | A4C49CE3197DFEA2007C860C /* Utils */,
180 | A4C49CE2197DFE94007C860C /* Vendor */,
181 | A4C0E793197CB2FE005DDFD0 /* Images.xcassets */,
182 | A4C0E782197CB2FE005DDFD0 /* Supporting Files */,
183 | );
184 | path = URLNavigation;
185 | sourceTree = "";
186 | };
187 | A4C0E782197CB2FE005DDFD0 /* Supporting Files */ = {
188 | isa = PBXGroup;
189 | children = (
190 | A4C0E783197CB2FE005DDFD0 /* URLNavigation-Info.plist */,
191 | A4C0E784197CB2FE005DDFD0 /* InfoPlist.strings */,
192 | A4C0E787197CB2FE005DDFD0 /* main.m */,
193 | A4C0E789197CB2FE005DDFD0 /* URLNavigation-Prefix.pch */,
194 | );
195 | name = "Supporting Files";
196 | sourceTree = "";
197 | };
198 | A4C0E7A0197CB2FE005DDFD0 /* URLNavigationTests */ = {
199 | isa = PBXGroup;
200 | children = (
201 | A4C0E7A6197CB2FE005DDFD0 /* URLNavigationTests.m */,
202 | A4C0E7A1197CB2FE005DDFD0 /* Supporting Files */,
203 | );
204 | path = URLNavigationTests;
205 | sourceTree = "";
206 | };
207 | A4C0E7A1197CB2FE005DDFD0 /* Supporting Files */ = {
208 | isa = PBXGroup;
209 | children = (
210 | A4C0E7A2197CB2FE005DDFD0 /* URLNavigationTests-Info.plist */,
211 | A4C0E7A3197CB2FE005DDFD0 /* InfoPlist.strings */,
212 | );
213 | name = "Supporting Files";
214 | sourceTree = "";
215 | };
216 | A4C0E7B6197CB3D9005DDFD0 /* Controller */ = {
217 | isa = PBXGroup;
218 | children = (
219 | A4C0E7D0197CBAAD005DDFD0 /* ViewControllers.h */,
220 | A4C0E7B8197CB403005DDFD0 /* BaseVC */,
221 | A4C0E7C0197CB599005DDFD0 /* AViewController.h */,
222 | A4C0E7C1197CB599005DDFD0 /* AViewController.m */,
223 | A4C0E7C3197CB5A5005DDFD0 /* BViewController.h */,
224 | A4C0E7C4197CB5A5005DDFD0 /* BViewController.m */,
225 | A4C0E7C6197CB5B0005DDFD0 /* CViewController.h */,
226 | A4C0E7C7197CB5B0005DDFD0 /* CViewController.m */,
227 | A4C0E7C9197CB5BC005DDFD0 /* DViewController.h */,
228 | A4C0E7CA197CB5BC005DDFD0 /* DViewController.m */,
229 | A4C0E7CC197CB5C7005DDFD0 /* EViewController.h */,
230 | A4C0E7CD197CB5C7005DDFD0 /* EViewController.m */,
231 | );
232 | name = Controller;
233 | sourceTree = "";
234 | };
235 | A4C0E7B8197CB403005DDFD0 /* BaseVC */ = {
236 | isa = PBXGroup;
237 | children = (
238 | A4C0E7B0197CB333005DDFD0 /* YQBaseViewController.h */,
239 | A4C0E7B1197CB333005DDFD0 /* YQBaseViewController.m */,
240 | A4C0E7B3197CB367005DDFD0 /* YQNavigationViewController.h */,
241 | A4C0E7B4197CB367005DDFD0 /* YQNavigationViewController.m */,
242 | );
243 | name = BaseVC;
244 | sourceTree = "";
245 | };
246 | A4C0E7B9197CB439005DDFD0 /* Extension */ = {
247 | isa = PBXGroup;
248 | children = (
249 | A4C0E7BA197CB439005DDFD0 /* NSString+YQ.h */,
250 | A4C0E7BB197CB439005DDFD0 /* NSString+YQ.m */,
251 | );
252 | path = Extension;
253 | sourceTree = SOURCE_ROOT;
254 | };
255 | A4C0E7D1197CC199005DDFD0 /* Model */ = {
256 | isa = PBXGroup;
257 | children = (
258 | A4C49CDE197DFE7A007C860C /* Sample.h */,
259 | A4C49CDF197DFE7A007C860C /* Sample.m */,
260 | );
261 | name = Model;
262 | sourceTree = "";
263 | };
264 | A4C0E7D2197CC1BC005DDFD0 /* Cache */ = {
265 | isa = PBXGroup;
266 | children = (
267 | A4C49CFD197DFF69007C860C /* YQCacheCenter.h */,
268 | A4C49CFE197DFF69007C860C /* YQCacheCenter.m */,
269 | );
270 | name = Cache;
271 | sourceTree = "";
272 | };
273 | A4C49CE1197DFE80007C860C /* DB */ = {
274 | isa = PBXGroup;
275 | children = (
276 | A4C49CFA197DFF58007C860C /* YQDBCenter.h */,
277 | A4C49CFB197DFF58007C860C /* YQDBCenter.m */,
278 | );
279 | name = DB;
280 | sourceTree = "";
281 | };
282 | A4C49CE2197DFE94007C860C /* Vendor */ = {
283 | isa = PBXGroup;
284 | children = (
285 | A4C49CE4197DFF30007C860C /* FMDB-v2.3 */,
286 | );
287 | name = Vendor;
288 | sourceTree = "";
289 | };
290 | A4C49CE3197DFEA2007C860C /* Utils */ = {
291 | isa = PBXGroup;
292 | children = (
293 | A4C49CE1197DFE80007C860C /* DB */,
294 | A4C0E7D2197CC1BC005DDFD0 /* Cache */,
295 | );
296 | name = Utils;
297 | sourceTree = "";
298 | };
299 | A4C49CE4197DFF30007C860C /* FMDB-v2.3 */ = {
300 | isa = PBXGroup;
301 | children = (
302 | A4C49CE5197DFF30007C860C /* extra */,
303 | A4C49CE8197DFF30007C860C /* fmdb */,
304 | );
305 | name = "FMDB-v2.3";
306 | path = "Vendor/FMDB-v2.3";
307 | sourceTree = SOURCE_ROOT;
308 | };
309 | A4C49CE5197DFF30007C860C /* extra */ = {
310 | isa = PBXGroup;
311 | children = (
312 | A4C49CE6197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.h */,
313 | A4C49CE7197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.m */,
314 | );
315 | path = extra;
316 | sourceTree = "";
317 | };
318 | A4C49CE8197DFF30007C860C /* fmdb */ = {
319 | isa = PBXGroup;
320 | children = (
321 | A4C49CE9197DFF30007C860C /* FMDatabase.h */,
322 | A4C49CEA197DFF30007C860C /* FMDatabase.m */,
323 | A4C49CEB197DFF30007C860C /* FMDatabaseAdditions.h */,
324 | A4C49CEC197DFF30007C860C /* FMDatabaseAdditions.m */,
325 | A4C49CED197DFF30007C860C /* FMDatabasePool.h */,
326 | A4C49CEE197DFF30007C860C /* FMDatabasePool.m */,
327 | A4C49CEF197DFF30007C860C /* FMDatabaseQueue.h */,
328 | A4C49CF0197DFF30007C860C /* FMDatabaseQueue.m */,
329 | A4C49CF1197DFF30007C860C /* FMDB.h */,
330 | A4C49CF2197DFF30007C860C /* FMResultSet.h */,
331 | A4C49CF3197DFF30007C860C /* FMResultSet.m */,
332 | );
333 | path = fmdb;
334 | sourceTree = "";
335 | };
336 | /* End PBXGroup section */
337 |
338 | /* Begin PBXNativeTarget section */
339 | A4C0E777197CB2FD005DDFD0 /* URLNavigation */ = {
340 | isa = PBXNativeTarget;
341 | buildConfigurationList = A4C0E7AA197CB2FE005DDFD0 /* Build configuration list for PBXNativeTarget "URLNavigation" */;
342 | buildPhases = (
343 | A4C0E774197CB2FD005DDFD0 /* Sources */,
344 | A4C0E775197CB2FD005DDFD0 /* Frameworks */,
345 | A4C0E776197CB2FD005DDFD0 /* Resources */,
346 | );
347 | buildRules = (
348 | );
349 | dependencies = (
350 | );
351 | name = URLNavigation;
352 | productName = URLNavigation;
353 | productReference = A4C0E778197CB2FD005DDFD0 /* URLNavigation.app */;
354 | productType = "com.apple.product-type.application";
355 | };
356 | A4C0E798197CB2FE005DDFD0 /* URLNavigationTests */ = {
357 | isa = PBXNativeTarget;
358 | buildConfigurationList = A4C0E7AD197CB2FE005DDFD0 /* Build configuration list for PBXNativeTarget "URLNavigationTests" */;
359 | buildPhases = (
360 | A4C0E795197CB2FE005DDFD0 /* Sources */,
361 | A4C0E796197CB2FE005DDFD0 /* Frameworks */,
362 | A4C0E797197CB2FE005DDFD0 /* Resources */,
363 | );
364 | buildRules = (
365 | );
366 | dependencies = (
367 | A4C0E79F197CB2FE005DDFD0 /* PBXTargetDependency */,
368 | );
369 | name = URLNavigationTests;
370 | productName = URLNavigationTests;
371 | productReference = A4C0E799197CB2FE005DDFD0 /* URLNavigationTests.xctest */;
372 | productType = "com.apple.product-type.bundle.unit-test";
373 | };
374 | /* End PBXNativeTarget section */
375 |
376 | /* Begin PBXProject section */
377 | A4C0E770197CB2FD005DDFD0 /* Project object */ = {
378 | isa = PBXProject;
379 | attributes = {
380 | LastUpgradeCheck = 0510;
381 | ORGANIZATIONNAME = Jasper;
382 | TargetAttributes = {
383 | A4C0E798197CB2FE005DDFD0 = {
384 | TestTargetID = A4C0E777197CB2FD005DDFD0;
385 | };
386 | };
387 | };
388 | buildConfigurationList = A4C0E773197CB2FD005DDFD0 /* Build configuration list for PBXProject "URLNavigation" */;
389 | compatibilityVersion = "Xcode 3.2";
390 | developmentRegion = English;
391 | hasScannedForEncodings = 0;
392 | knownRegions = (
393 | en,
394 | Base,
395 | );
396 | mainGroup = A4C0E76F197CB2FD005DDFD0;
397 | productRefGroup = A4C0E779197CB2FD005DDFD0 /* Products */;
398 | projectDirPath = "";
399 | projectRoot = "";
400 | targets = (
401 | A4C0E777197CB2FD005DDFD0 /* URLNavigation */,
402 | A4C0E798197CB2FE005DDFD0 /* URLNavigationTests */,
403 | );
404 | };
405 | /* End PBXProject section */
406 |
407 | /* Begin PBXResourcesBuildPhase section */
408 | A4C0E776197CB2FD005DDFD0 /* Resources */ = {
409 | isa = PBXResourcesBuildPhase;
410 | buildActionMask = 2147483647;
411 | files = (
412 | A4C0E794197CB2FE005DDFD0 /* Images.xcassets in Resources */,
413 | A4C0E786197CB2FE005DDFD0 /* InfoPlist.strings in Resources */,
414 | );
415 | runOnlyForDeploymentPostprocessing = 0;
416 | };
417 | A4C0E797197CB2FE005DDFD0 /* Resources */ = {
418 | isa = PBXResourcesBuildPhase;
419 | buildActionMask = 2147483647;
420 | files = (
421 | A4C0E7A5197CB2FE005DDFD0 /* InfoPlist.strings in Resources */,
422 | );
423 | runOnlyForDeploymentPostprocessing = 0;
424 | };
425 | /* End PBXResourcesBuildPhase section */
426 |
427 | /* Begin PBXSourcesBuildPhase section */
428 | A4C0E774197CB2FD005DDFD0 /* Sources */ = {
429 | isa = PBXSourcesBuildPhase;
430 | buildActionMask = 2147483647;
431 | files = (
432 | A4C0E7CB197CB5BC005DDFD0 /* DViewController.m in Sources */,
433 | A4C49CFF197DFF69007C860C /* YQCacheCenter.m in Sources */,
434 | A4C49CF4197DFF30007C860C /* FMDatabase+InMemoryOnDiskIO.m in Sources */,
435 | A4C0E7C8197CB5B0005DDFD0 /* CViewController.m in Sources */,
436 | A4C49CF5197DFF30007C860C /* FMDatabase.m in Sources */,
437 | A4C0E7BC197CB439005DDFD0 /* NSString+YQ.m in Sources */,
438 | A4C0E7CE197CB5C7005DDFD0 /* EViewController.m in Sources */,
439 | A4C49CF9197DFF30007C860C /* FMResultSet.m in Sources */,
440 | A4C0E7B2197CB333005DDFD0 /* YQBaseViewController.m in Sources */,
441 | A4C0E78C197CB2FE005DDFD0 /* AppDelegate.m in Sources */,
442 | A4C0E7C5197CB5A5005DDFD0 /* BViewController.m in Sources */,
443 | A4C0E7C2197CB599005DDFD0 /* AViewController.m in Sources */,
444 | A4C0E7BF197CB496005DDFD0 /* YQNavigator.m in Sources */,
445 | A4C49CE0197DFE7A007C860C /* Sample.m in Sources */,
446 | A4C0E7B5197CB367005DDFD0 /* YQNavigationViewController.m in Sources */,
447 | A4C49CF7197DFF30007C860C /* FMDatabasePool.m in Sources */,
448 | A4C49CF8197DFF30007C860C /* FMDatabaseQueue.m in Sources */,
449 | A4C49CFC197DFF58007C860C /* YQDBCenter.m in Sources */,
450 | A4C0E788197CB2FE005DDFD0 /* main.m in Sources */,
451 | A4C49CF6197DFF30007C860C /* FMDatabaseAdditions.m in Sources */,
452 | );
453 | runOnlyForDeploymentPostprocessing = 0;
454 | };
455 | A4C0E795197CB2FE005DDFD0 /* Sources */ = {
456 | isa = PBXSourcesBuildPhase;
457 | buildActionMask = 2147483647;
458 | files = (
459 | A4C0E7A7197CB2FE005DDFD0 /* URLNavigationTests.m in Sources */,
460 | );
461 | runOnlyForDeploymentPostprocessing = 0;
462 | };
463 | /* End PBXSourcesBuildPhase section */
464 |
465 | /* Begin PBXTargetDependency section */
466 | A4C0E79F197CB2FE005DDFD0 /* PBXTargetDependency */ = {
467 | isa = PBXTargetDependency;
468 | target = A4C0E777197CB2FD005DDFD0 /* URLNavigation */;
469 | targetProxy = A4C0E79E197CB2FE005DDFD0 /* PBXContainerItemProxy */;
470 | };
471 | /* End PBXTargetDependency section */
472 |
473 | /* Begin PBXVariantGroup section */
474 | A4C0E784197CB2FE005DDFD0 /* InfoPlist.strings */ = {
475 | isa = PBXVariantGroup;
476 | children = (
477 | A4C0E785197CB2FE005DDFD0 /* en */,
478 | );
479 | name = InfoPlist.strings;
480 | sourceTree = "";
481 | };
482 | A4C0E7A3197CB2FE005DDFD0 /* InfoPlist.strings */ = {
483 | isa = PBXVariantGroup;
484 | children = (
485 | A4C0E7A4197CB2FE005DDFD0 /* en */,
486 | );
487 | name = InfoPlist.strings;
488 | sourceTree = "";
489 | };
490 | /* End PBXVariantGroup section */
491 |
492 | /* Begin XCBuildConfiguration section */
493 | A4C0E7A8197CB2FE005DDFD0 /* Debug */ = {
494 | isa = XCBuildConfiguration;
495 | buildSettings = {
496 | ALWAYS_SEARCH_USER_PATHS = NO;
497 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
498 | CLANG_CXX_LIBRARY = "libc++";
499 | CLANG_ENABLE_MODULES = YES;
500 | CLANG_ENABLE_OBJC_ARC = YES;
501 | CLANG_WARN_BOOL_CONVERSION = YES;
502 | CLANG_WARN_CONSTANT_CONVERSION = YES;
503 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
504 | CLANG_WARN_EMPTY_BODY = YES;
505 | CLANG_WARN_ENUM_CONVERSION = YES;
506 | CLANG_WARN_INT_CONVERSION = YES;
507 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
508 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
509 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
510 | COPY_PHASE_STRIP = NO;
511 | GCC_C_LANGUAGE_STANDARD = gnu99;
512 | GCC_DYNAMIC_NO_PIC = NO;
513 | GCC_OPTIMIZATION_LEVEL = 0;
514 | GCC_PREPROCESSOR_DEFINITIONS = (
515 | "DEBUG=1",
516 | "$(inherited)",
517 | );
518 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
519 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
520 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
521 | GCC_WARN_UNDECLARED_SELECTOR = YES;
522 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
523 | GCC_WARN_UNUSED_FUNCTION = YES;
524 | GCC_WARN_UNUSED_VARIABLE = YES;
525 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
526 | ONLY_ACTIVE_ARCH = YES;
527 | SDKROOT = iphoneos;
528 | };
529 | name = Debug;
530 | };
531 | A4C0E7A9197CB2FE005DDFD0 /* Release */ = {
532 | isa = XCBuildConfiguration;
533 | buildSettings = {
534 | ALWAYS_SEARCH_USER_PATHS = NO;
535 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
536 | CLANG_CXX_LIBRARY = "libc++";
537 | CLANG_ENABLE_MODULES = YES;
538 | CLANG_ENABLE_OBJC_ARC = YES;
539 | CLANG_WARN_BOOL_CONVERSION = YES;
540 | CLANG_WARN_CONSTANT_CONVERSION = YES;
541 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
542 | CLANG_WARN_EMPTY_BODY = YES;
543 | CLANG_WARN_ENUM_CONVERSION = YES;
544 | CLANG_WARN_INT_CONVERSION = YES;
545 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
546 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
547 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
548 | COPY_PHASE_STRIP = YES;
549 | ENABLE_NS_ASSERTIONS = NO;
550 | GCC_C_LANGUAGE_STANDARD = gnu99;
551 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
552 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
553 | GCC_WARN_UNDECLARED_SELECTOR = YES;
554 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
555 | GCC_WARN_UNUSED_FUNCTION = YES;
556 | GCC_WARN_UNUSED_VARIABLE = YES;
557 | IPHONEOS_DEPLOYMENT_TARGET = 7.1;
558 | SDKROOT = iphoneos;
559 | VALIDATE_PRODUCT = YES;
560 | };
561 | name = Release;
562 | };
563 | A4C0E7AB197CB2FE005DDFD0 /* Debug */ = {
564 | isa = XCBuildConfiguration;
565 | buildSettings = {
566 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
567 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
568 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
569 | GCC_PREFIX_HEADER = "URLNavigation/URLNavigation-Prefix.pch";
570 | INFOPLIST_FILE = "URLNavigation/URLNavigation-Info.plist";
571 | PRODUCT_NAME = "$(TARGET_NAME)";
572 | WRAPPER_EXTENSION = app;
573 | };
574 | name = Debug;
575 | };
576 | A4C0E7AC197CB2FE005DDFD0 /* Release */ = {
577 | isa = XCBuildConfiguration;
578 | buildSettings = {
579 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
580 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
581 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
582 | GCC_PREFIX_HEADER = "URLNavigation/URLNavigation-Prefix.pch";
583 | INFOPLIST_FILE = "URLNavigation/URLNavigation-Info.plist";
584 | PRODUCT_NAME = "$(TARGET_NAME)";
585 | WRAPPER_EXTENSION = app;
586 | };
587 | name = Release;
588 | };
589 | A4C0E7AE197CB2FE005DDFD0 /* Debug */ = {
590 | isa = XCBuildConfiguration;
591 | buildSettings = {
592 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/URLNavigation.app/URLNavigation";
593 | FRAMEWORK_SEARCH_PATHS = (
594 | "$(SDKROOT)/Developer/Library/Frameworks",
595 | "$(inherited)",
596 | "$(DEVELOPER_FRAMEWORKS_DIR)",
597 | );
598 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
599 | GCC_PREFIX_HEADER = "URLNavigation/URLNavigation-Prefix.pch";
600 | GCC_PREPROCESSOR_DEFINITIONS = (
601 | "DEBUG=1",
602 | "$(inherited)",
603 | );
604 | INFOPLIST_FILE = "URLNavigationTests/URLNavigationTests-Info.plist";
605 | PRODUCT_NAME = "$(TARGET_NAME)";
606 | TEST_HOST = "$(BUNDLE_LOADER)";
607 | WRAPPER_EXTENSION = xctest;
608 | };
609 | name = Debug;
610 | };
611 | A4C0E7AF197CB2FE005DDFD0 /* Release */ = {
612 | isa = XCBuildConfiguration;
613 | buildSettings = {
614 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/URLNavigation.app/URLNavigation";
615 | FRAMEWORK_SEARCH_PATHS = (
616 | "$(SDKROOT)/Developer/Library/Frameworks",
617 | "$(inherited)",
618 | "$(DEVELOPER_FRAMEWORKS_DIR)",
619 | );
620 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
621 | GCC_PREFIX_HEADER = "URLNavigation/URLNavigation-Prefix.pch";
622 | INFOPLIST_FILE = "URLNavigationTests/URLNavigationTests-Info.plist";
623 | PRODUCT_NAME = "$(TARGET_NAME)";
624 | TEST_HOST = "$(BUNDLE_LOADER)";
625 | WRAPPER_EXTENSION = xctest;
626 | };
627 | name = Release;
628 | };
629 | /* End XCBuildConfiguration section */
630 |
631 | /* Begin XCConfigurationList section */
632 | A4C0E773197CB2FD005DDFD0 /* Build configuration list for PBXProject "URLNavigation" */ = {
633 | isa = XCConfigurationList;
634 | buildConfigurations = (
635 | A4C0E7A8197CB2FE005DDFD0 /* Debug */,
636 | A4C0E7A9197CB2FE005DDFD0 /* Release */,
637 | );
638 | defaultConfigurationIsVisible = 0;
639 | defaultConfigurationName = Release;
640 | };
641 | A4C0E7AA197CB2FE005DDFD0 /* Build configuration list for PBXNativeTarget "URLNavigation" */ = {
642 | isa = XCConfigurationList;
643 | buildConfigurations = (
644 | A4C0E7AB197CB2FE005DDFD0 /* Debug */,
645 | A4C0E7AC197CB2FE005DDFD0 /* Release */,
646 | );
647 | defaultConfigurationIsVisible = 0;
648 | defaultConfigurationName = Release;
649 | };
650 | A4C0E7AD197CB2FE005DDFD0 /* Build configuration list for PBXNativeTarget "URLNavigationTests" */ = {
651 | isa = XCConfigurationList;
652 | buildConfigurations = (
653 | A4C0E7AE197CB2FE005DDFD0 /* Debug */,
654 | A4C0E7AF197CB2FE005DDFD0 /* Release */,
655 | );
656 | defaultConfigurationIsVisible = 0;
657 | defaultConfigurationName = Release;
658 | };
659 | /* End XCConfigurationList section */
660 | };
661 | rootObject = A4C0E770197CB2FD005DDFD0 /* Project object */;
662 | }
663 |
--------------------------------------------------------------------------------
/Vendor/FMDB-v2.3/fmdb/FMDatabase.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "sqlite3.h"
3 | #import "FMResultSet.h"
4 | #import "FMDatabasePool.h"
5 |
6 |
7 | #if ! __has_feature(objc_arc)
8 | #define FMDBAutorelease(__v) ([__v autorelease]);
9 | #define FMDBReturnAutoreleased FMDBAutorelease
10 |
11 | #define FMDBRetain(__v) ([__v retain]);
12 | #define FMDBReturnRetained FMDBRetain
13 |
14 | #define FMDBRelease(__v) ([__v release]);
15 |
16 | #define FMDBDispatchQueueRelease(__v) (dispatch_release(__v));
17 | #else
18 | // -fobjc-arc
19 | #define FMDBAutorelease(__v)
20 | #define FMDBReturnAutoreleased(__v) (__v)
21 |
22 | #define FMDBRetain(__v)
23 | #define FMDBReturnRetained(__v) (__v)
24 |
25 | #define FMDBRelease(__v)
26 |
27 | // If OS_OBJECT_USE_OBJC=1, then the dispatch objects will be treated like ObjC objects
28 | // and will participate in ARC.
29 | // See the section on "Dispatch Queues and Automatic Reference Counting" in "Grand Central Dispatch (GCD) Reference" for details.
30 | #if OS_OBJECT_USE_OBJC
31 | #define FMDBDispatchQueueRelease(__v)
32 | #else
33 | #define FMDBDispatchQueueRelease(__v) (dispatch_release(__v));
34 | #endif
35 | #endif
36 |
37 | #if !__has_feature(objc_instancetype)
38 | #define instancetype id
39 | #endif
40 |
41 |
42 | typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary);
43 |
44 |
45 | /** A SQLite ([http://sqlite.org/](http://sqlite.org/)) Objective-C wrapper.
46 |
47 | ### Usage
48 | The three main classes in FMDB are:
49 |
50 | - `FMDatabase` - Represents a single SQLite database. Used for executing SQL statements.
51 | - `` - Represents the results of executing a query on an `FMDatabase`.
52 | - `` - If you want to perform queries and updates on multiple threads, you'll want to use this class.
53 |
54 | ### See also
55 |
56 | - `` - A pool of `FMDatabase` objects.
57 | - `` - A wrapper for `sqlite_stmt`.
58 |
59 | ### External links
60 |
61 | - [FMDB on GitHub](https://github.com/ccgus/fmdb) including introductory documentation
62 | - [SQLite web site](http://sqlite.org/)
63 | - [FMDB mailing list](http://groups.google.com/group/fmdb)
64 | - [SQLite FAQ](http://www.sqlite.org/faq.html)
65 |
66 | @warning Do not instantiate a single `FMDatabase` object and use it across multiple threads. Instead, use ``.
67 |
68 | */
69 |
70 | @interface FMDatabase : NSObject {
71 |
72 | sqlite3* _db;
73 | NSString* _databasePath;
74 | BOOL _logsErrors;
75 | BOOL _crashOnErrors;
76 | BOOL _traceExecution;
77 | BOOL _checkedOut;
78 | BOOL _shouldCacheStatements;
79 | BOOL _isExecutingStatement;
80 | BOOL _inTransaction;
81 | NSTimeInterval _maxBusyRetryTimeInterval;
82 | NSTimeInterval _startBusyRetryTime;
83 |
84 | NSMutableDictionary *_cachedStatements;
85 | NSMutableSet *_openResultSets;
86 | NSMutableSet *_openFunctions;
87 |
88 | NSDateFormatter *_dateFormat;
89 | }
90 |
91 | ///-----------------
92 | /// @name Properties
93 | ///-----------------
94 |
95 | /** Whether should trace execution */
96 |
97 | @property (atomic, assign) BOOL traceExecution;
98 |
99 | /** Whether checked out or not */
100 |
101 | @property (atomic, assign) BOOL checkedOut;
102 |
103 | /** Crash on errors */
104 |
105 | @property (atomic, assign) BOOL crashOnErrors;
106 |
107 | /** Logs errors */
108 |
109 | @property (atomic, assign) BOOL logsErrors;
110 |
111 | /** Dictionary of cached statements */
112 |
113 | @property (atomic, retain) NSMutableDictionary *cachedStatements;
114 |
115 | ///---------------------
116 | /// @name Initialization
117 | ///---------------------
118 |
119 | /** Create a `FMDatabase` object.
120 |
121 | An `FMDatabase` is created with a path to a SQLite database file. This path can be one of these three:
122 |
123 | 1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
124 | 2. An empty string (`@""`). An empty database is created at a temporary location. This database is deleted with the `FMDatabase` connection is closed.
125 | 3. `nil`. An in-memory database is created. This database will be destroyed with the `FMDatabase` connection is closed.
126 |
127 | For example, to create/open a database in your Mac OS X `tmp` folder:
128 |
129 | FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
130 |
131 | Or, in iOS, you might open a database in the app's `Documents` directory:
132 |
133 | NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
134 | NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
135 | FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
136 |
137 | (For more information on temporary and in-memory databases, read the sqlite documentation on the subject: [http://www.sqlite.org/inmemorydb.html](http://www.sqlite.org/inmemorydb.html))
138 |
139 | @param inPath Path of database file
140 |
141 | @return `FMDatabase` object if successful; `nil` if failure.
142 |
143 | */
144 |
145 | + (instancetype)databaseWithPath:(NSString*)inPath;
146 |
147 | /** Initialize a `FMDatabase` object.
148 |
149 | An `FMDatabase` is created with a path to a SQLite database file. This path can be one of these three:
150 |
151 | 1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
152 | 2. An empty string (`@""`). An empty database is created at a temporary location. This database is deleted with the `FMDatabase` connection is closed.
153 | 3. `nil`. An in-memory database is created. This database will be destroyed with the `FMDatabase` connection is closed.
154 |
155 | For example, to create/open a database in your Mac OS X `tmp` folder:
156 |
157 | FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
158 |
159 | Or, in iOS, you might open a database in the app's `Documents` directory:
160 |
161 | NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
162 | NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
163 | FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
164 |
165 | (For more information on temporary and in-memory databases, read the sqlite documentation on the subject: [http://www.sqlite.org/inmemorydb.html](http://www.sqlite.org/inmemorydb.html))
166 |
167 | @param inPath Path of database file
168 |
169 | @return `FMDatabase` object if successful; `nil` if failure.
170 |
171 | */
172 |
173 | - (instancetype)initWithPath:(NSString*)inPath;
174 |
175 |
176 | ///-----------------------------------
177 | /// @name Opening and closing database
178 | ///-----------------------------------
179 |
180 | /** Opening a new database connection
181 |
182 | The database is opened for reading and writing, and is created if it does not already exist.
183 |
184 | @return `YES` if successful, `NO` on error.
185 |
186 | @see [sqlite3_open()](http://sqlite.org/c3ref/open.html)
187 | @see openWithFlags:
188 | @see close
189 | */
190 |
191 | - (BOOL)open;
192 |
193 | /** Opening a new database connection with flags
194 |
195 | @param flags one of the following three values, optionally combined with the `SQLITE_OPEN_NOMUTEX`, `SQLITE_OPEN_FULLMUTEX`, `SQLITE_OPEN_SHAREDCACHE`, `SQLITE_OPEN_PRIVATECACHE`, and/or `SQLITE_OPEN_URI` flags:
196 |
197 | `SQLITE_OPEN_READONLY`
198 |
199 | The database is opened in read-only mode. If the database does not already exist, an error is returned.
200 |
201 | `SQLITE_OPEN_READWRITE`
202 |
203 | The database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned.
204 |
205 | `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE`
206 |
207 | The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for `open` method.
208 |
209 | @return `YES` if successful, `NO` on error.
210 |
211 | @see [sqlite3_open_v2()](http://sqlite.org/c3ref/open.html)
212 | @see open
213 | @see close
214 | */
215 |
216 | #if SQLITE_VERSION_NUMBER >= 3005000
217 | - (BOOL)openWithFlags:(int)flags;
218 | #endif
219 |
220 | /** Closing a database connection
221 |
222 | @return `YES` if success, `NO` on error.
223 |
224 | @see [sqlite3_close()](http://sqlite.org/c3ref/close.html)
225 | @see open
226 | @see openWithFlags:
227 | */
228 |
229 | - (BOOL)close;
230 |
231 | /** Test to see if we have a good connection to the database.
232 |
233 | This will confirm whether:
234 |
235 | - is database open
236 | - if open, it will try a simple SELECT statement and confirm that it succeeds.
237 |
238 | @return `YES` if everything succeeds, `NO` on failure.
239 | */
240 |
241 | - (BOOL)goodConnection;
242 |
243 |
244 | ///----------------------
245 | /// @name Perform updates
246 | ///----------------------
247 |
248 | /** Execute single update statement
249 |
250 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html), [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) to bind values to `?` placeholders in the SQL with the optional list of parameters, and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update.
251 |
252 | The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
253 |
254 | @param sql The SQL to be performed, with optional `?` placeholders.
255 |
256 | @param outErr A reference to the `NSError` pointer to be updated with an auto released `NSError` object if an error if an error occurs. If `nil`, no `NSError` object will be returned.
257 |
258 | @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
259 |
260 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
261 |
262 | @see lastError
263 | @see lastErrorCode
264 | @see lastErrorMessage
265 | @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
266 | */
267 |
268 | - (BOOL)executeUpdate:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ...;
269 |
270 | /** Execute single update statement
271 |
272 | @see executeUpdate:withErrorAndBindings:
273 |
274 | @warning **Deprecated**: Please use `` instead.
275 | */
276 |
277 | - (BOOL)update:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ... __attribute__ ((deprecated));
278 |
279 | /** Execute single update statement
280 |
281 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html), [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) to bind values to `?` placeholders in the SQL with the optional list of parameters, and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update.
282 |
283 | The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
284 |
285 | @param sql The SQL to be performed, with optional `?` placeholders.
286 |
287 | @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
288 |
289 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
290 |
291 | @see lastError
292 | @see lastErrorCode
293 | @see lastErrorMessage
294 | @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
295 |
296 | @note This technique supports the use of `?` placeholders in the SQL, automatically binding any supplied value parameters to those placeholders. This approach is more robust than techniques that entail using `stringWithFormat` to manually build SQL statements, which can be problematic if the values happened to include any characters that needed to be quoted.
297 | */
298 |
299 | - (BOOL)executeUpdate:(NSString*)sql, ...;
300 |
301 | /** Execute single update statement
302 |
303 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL. Do not use `?` placeholders in the SQL if you use this method.
304 |
305 | @param format The SQL to be performed, with `printf`-style escape sequences.
306 |
307 | @param ... Optional parameters to bind to use in conjunction with the `printf`-style escape sequences in the SQL statement.
308 |
309 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
310 |
311 | @see executeUpdate:
312 | @see lastError
313 | @see lastErrorCode
314 | @see lastErrorMessage
315 |
316 | @warning This should be used with great care. Generally, instead of this method, you should use `` (with `?` placeholders in the SQL), which properly escapes quotation marks encountered inside the values (minimizing errors and protecting against SQL injection attack) and handles a wider variety of data types. See `` for more information.
317 | */
318 |
319 | - (BOOL)executeUpdateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
320 |
321 | /** Execute single update statement
322 |
323 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) binding any `?` placeholders in the SQL with the optional list of parameters.
324 |
325 | The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
326 |
327 | @param sql The SQL to be performed, with optional `?` placeholders.
328 |
329 | @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
330 |
331 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
332 |
333 | @see lastError
334 | @see lastErrorCode
335 | @see lastErrorMessage
336 | */
337 |
338 | - (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
339 |
340 | /** Execute single update statement
341 |
342 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
343 |
344 | The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
345 |
346 | @param sql The SQL to be performed, with optional `?` placeholders.
347 |
348 | @param arguments A `NSDictionary` of objects keyed by column names that will be used when binding values to the `?` placeholders in the SQL statement.
349 |
350 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
351 |
352 | @see lastError
353 | @see lastErrorCode
354 | @see lastErrorMessage
355 | */
356 |
357 | - (BOOL)executeUpdate:(NSString*)sql withParameterDictionary:(NSDictionary *)arguments;
358 |
359 |
360 | /** Execute single update statement
361 |
362 | This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
363 |
364 | The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
365 |
366 | @param sql The SQL to be performed, with optional `?` placeholders.
367 |
368 | @param args A `va_list` of arguments.
369 |
370 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
371 |
372 | @see lastError
373 | @see lastErrorCode
374 | @see lastErrorMessage
375 | */
376 |
377 | - (BOOL)executeUpdate:(NSString*)sql withVAList: (va_list)args;
378 |
379 | /** Execute multiple SQL statements
380 |
381 | This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
382 |
383 | @param sql The SQL to be performed
384 |
385 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
386 |
387 | @see executeStatements:withResultBlock:
388 | @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
389 |
390 | */
391 |
392 | - (BOOL)executeStatements:(NSString *)sql;
393 |
394 | /** Execute multiple SQL statements with callback handler
395 |
396 | This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
397 |
398 | @param sql The SQL to be performed.
399 | @param block A block that will be called for any result sets returned by any SQL statements.
400 | Note, if you supply this block, it must return integer value, zero upon success (this would be a good opportunity to use SQLITE_OK),
401 | non-zero value upon failure (which will stop the bulk execution of the SQL). If a statement returns values, the block will be called with the results from the query in NSDictionary *resultsDictionary.
402 | This may be `nil` if you don't care to receive any results.
403 |
404 | @return `YES` upon success; `NO` upon failure. If failed, you can call ``,
405 | ``, or `` for diagnostic information regarding the failure.
406 |
407 | @see executeStatements:
408 | @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
409 |
410 | */
411 |
412 | - (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMDBExecuteStatementsCallbackBlock)block;
413 |
414 | /** Last insert rowid
415 |
416 | Each entry in an SQLite table has a unique 64-bit signed integer key called the "rowid". The rowid is always available as an undeclared column named `ROWID`, `OID`, or `_ROWID_` as long as those names are not also used by explicitly declared columns. If the table has a column of type `INTEGER PRIMARY KEY` then that column is another alias for the rowid.
417 |
418 | This routine returns the rowid of the most recent successful `INSERT` into the database from the database connection in the first argument. As of SQLite version 3.7.7, this routines records the last insert rowid of both ordinary tables and virtual tables. If no successful `INSERT`s have ever occurred on that database connection, zero is returned.
419 |
420 | @return The rowid of the last inserted row.
421 |
422 | @see [sqlite3_last_insert_rowid()](http://sqlite.org/c3ref/last_insert_rowid.html)
423 |
424 | */
425 |
426 | - (sqlite_int64)lastInsertRowId;
427 |
428 | /** The number of rows changed by prior SQL statement.
429 |
430 | This function returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the database connection specified by the first parameter. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted.
431 |
432 | @return The number of rows changed by prior SQL statement.
433 |
434 | @see [sqlite3_changes()](http://sqlite.org/c3ref/changes.html)
435 |
436 | */
437 |
438 | - (int)changes;
439 |
440 |
441 | ///-------------------------
442 | /// @name Retrieving results
443 | ///-------------------------
444 |
445 | /** Execute select statement
446 |
447 | Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
448 |
449 | In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
450 |
451 | This method employs [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) for any optional value parameters. This properly escapes any characters that need escape sequences (e.g. quotation marks), which eliminates simple SQL errors as well as protects against SQL injection attacks. This method natively handles `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects. All other object types will be interpreted as text values using the object's `description` method.
452 |
453 | @param sql The SELECT statement to be performed, with optional `?` placeholders.
454 |
455 | @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
456 |
457 | @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
458 |
459 | @see FMResultSet
460 | @see [`FMResultSet next`](<[FMResultSet next]>)
461 | @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
462 | */
463 |
464 | - (FMResultSet *)executeQuery:(NSString*)sql, ...;
465 |
466 | /** Execute select statement
467 |
468 | Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
469 |
470 | In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
471 |
472 | @param format The SQL to be performed, with `printf`-style escape sequences.
473 |
474 | @param ... Optional parameters to bind to use in conjunction with the `printf`-style escape sequences in the SQL statement.
475 |
476 | @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
477 |
478 | @see executeQuery:
479 | @see FMResultSet
480 | @see [`FMResultSet next`](<[FMResultSet next]>)
481 |
482 | @warning This should be used with great care. Generally, instead of this method, you should use `` (with `?` placeholders in the SQL), which properly escapes quotation marks encountered inside the values (minimizing errors and protecting against SQL injection attack) and handles a wider variety of data types. See `` for more information.
483 |
484 | */
485 |
486 | - (FMResultSet *)executeQueryWithFormat:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
487 |
488 | /** Execute select statement
489 |
490 | Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
491 |
492 | In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
493 |
494 | @param sql The SELECT statement to be performed, with optional `?` placeholders.
495 |
496 | @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
497 |
498 | @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
499 |
500 | @see FMResultSet
501 | @see [`FMResultSet next`](<[FMResultSet next]>)
502 | */
503 |
504 | - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments;
505 |
506 | /** Execute select statement
507 |
508 | Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
509 |
510 | In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
511 |
512 | @param sql The SELECT statement to be performed, with optional `?` placeholders.
513 |
514 | @param arguments A `NSDictionary` of objects keyed by column names that will be used when binding values to the `?` placeholders in the SQL statement.
515 |
516 | @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
517 |
518 | @see FMResultSet
519 | @see [`FMResultSet next`](<[FMResultSet next]>)
520 | */
521 |
522 | - (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments;
523 |
524 |
525 | // Documentation forthcoming.
526 | - (FMResultSet *)executeQuery:(NSString*)sql withVAList: (va_list)args;
527 |
528 | ///-------------------
529 | /// @name Transactions
530 | ///-------------------
531 |
532 | /** Begin a transaction
533 |
534 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
535 |
536 | @see commit
537 | @see rollback
538 | @see beginDeferredTransaction
539 | @see inTransaction
540 | */
541 |
542 | - (BOOL)beginTransaction;
543 |
544 | /** Begin a deferred transaction
545 |
546 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
547 |
548 | @see commit
549 | @see rollback
550 | @see beginTransaction
551 | @see inTransaction
552 | */
553 |
554 | - (BOOL)beginDeferredTransaction;
555 |
556 | /** Commit a transaction
557 |
558 | Commit a transaction that was initiated with either `` or with ``.
559 |
560 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
561 |
562 | @see beginTransaction
563 | @see beginDeferredTransaction
564 | @see rollback
565 | @see inTransaction
566 | */
567 |
568 | - (BOOL)commit;
569 |
570 | /** Rollback a transaction
571 |
572 | Rollback a transaction that was initiated with either `` or with ``.
573 |
574 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
575 |
576 | @see beginTransaction
577 | @see beginDeferredTransaction
578 | @see commit
579 | @see inTransaction
580 | */
581 |
582 | - (BOOL)rollback;
583 |
584 | /** Identify whether currently in a transaction or not
585 |
586 | @return `YES` if currently within transaction; `NO` if not.
587 |
588 | @see beginTransaction
589 | @see beginDeferredTransaction
590 | @see commit
591 | @see rollback
592 | */
593 |
594 | - (BOOL)inTransaction;
595 |
596 |
597 | ///----------------------------------------
598 | /// @name Cached statements and result sets
599 | ///----------------------------------------
600 |
601 | /** Clear cached statements */
602 |
603 | - (void)clearCachedStatements;
604 |
605 | /** Close all open result sets */
606 |
607 | - (void)closeOpenResultSets;
608 |
609 | /** Whether database has any open result sets
610 |
611 | @return `YES` if there are open result sets; `NO` if not.
612 | */
613 |
614 | - (BOOL)hasOpenResultSets;
615 |
616 | /** Return whether should cache statements or not
617 |
618 | @return `YES` if should cache statements; `NO` if not.
619 | */
620 |
621 | - (BOOL)shouldCacheStatements;
622 |
623 | /** Set whether should cache statements or not
624 |
625 | @param value `YES` if should cache statements; `NO` if not.
626 | */
627 |
628 | - (void)setShouldCacheStatements:(BOOL)value;
629 |
630 |
631 | ///-------------------------
632 | /// @name Encryption methods
633 | ///-------------------------
634 |
635 | /** Set encryption key.
636 |
637 | @param key The key to be used.
638 |
639 | @return `YES` if success, `NO` on error.
640 |
641 | @see http://www.sqlite-encrypt.com/develop-guide.htm
642 |
643 | @warning You need to have purchased the sqlite encryption extensions for this method to work.
644 | */
645 |
646 | - (BOOL)setKey:(NSString*)key;
647 |
648 | /** Reset encryption key
649 |
650 | @param key The key to be used.
651 |
652 | @return `YES` if success, `NO` on error.
653 |
654 | @see http://www.sqlite-encrypt.com/develop-guide.htm
655 |
656 | @warning You need to have purchased the sqlite encryption extensions for this method to work.
657 | */
658 |
659 | - (BOOL)rekey:(NSString*)key;
660 |
661 | /** Set encryption key using `keyData`.
662 |
663 | @param keyData The `NSData` to be used.
664 |
665 | @return `YES` if success, `NO` on error.
666 |
667 | @see http://www.sqlite-encrypt.com/develop-guide.htm
668 |
669 | @warning You need to have purchased the sqlite encryption extensions for this method to work.
670 | */
671 |
672 | - (BOOL)setKeyWithData:(NSData *)keyData;
673 |
674 | /** Reset encryption key using `keyData`.
675 |
676 | @param keyData The `NSData` to be used.
677 |
678 | @return `YES` if success, `NO` on error.
679 |
680 | @see http://www.sqlite-encrypt.com/develop-guide.htm
681 |
682 | @warning You need to have purchased the sqlite encryption extensions for this method to work.
683 | */
684 |
685 | - (BOOL)rekeyWithData:(NSData *)keyData;
686 |
687 |
688 | ///------------------------------
689 | /// @name General inquiry methods
690 | ///------------------------------
691 |
692 | /** The path of the database file
693 |
694 | @return path of database.
695 |
696 | */
697 |
698 | - (NSString *)databasePath;
699 |
700 | /** The underlying SQLite handle
701 |
702 | @return The `sqlite3` pointer.
703 |
704 | */
705 |
706 | - (sqlite3*)sqliteHandle;
707 |
708 |
709 | ///-----------------------------
710 | /// @name Retrieving error codes
711 | ///-----------------------------
712 |
713 | /** Last error message
714 |
715 | Returns the English-language text that describes the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
716 |
717 | @return `NSString` of the last error message.
718 |
719 | @see [sqlite3_errmsg()](http://sqlite.org/c3ref/errcode.html)
720 | @see lastErrorCode
721 | @see lastError
722 |
723 | */
724 |
725 | - (NSString*)lastErrorMessage;
726 |
727 | /** Last error code
728 |
729 | Returns the numeric result code or extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
730 |
731 | @return Integer value of the last error code.
732 |
733 | @see [sqlite3_errcode()](http://sqlite.org/c3ref/errcode.html)
734 | @see lastErrorMessage
735 | @see lastError
736 |
737 | */
738 |
739 | - (int)lastErrorCode;
740 |
741 | /** Had error
742 |
743 | @return `YES` if there was an error, `NO` if no error.
744 |
745 | @see lastError
746 | @see lastErrorCode
747 | @see lastErrorMessage
748 |
749 | */
750 |
751 | - (BOOL)hadError;
752 |
753 | /** Last error
754 |
755 | @return `NSError` representing the last error.
756 |
757 | @see lastErrorCode
758 | @see lastErrorMessage
759 |
760 | */
761 |
762 | - (NSError*)lastError;
763 |
764 |
765 | // description forthcoming
766 | - (void)setMaxBusyRetryTimeInterval:(NSTimeInterval)timeoutInSeconds;
767 | - (NSTimeInterval)maxBusyRetryTimeInterval;
768 |
769 |
770 | #if SQLITE_VERSION_NUMBER >= 3007000
771 |
772 | ///------------------
773 | /// @name Save points
774 | ///------------------
775 |
776 | /** Start save point
777 |
778 | @param name Name of save point.
779 |
780 | @param outErr A `NSError` object to receive any error object (if any).
781 |
782 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
783 |
784 | @see releaseSavePointWithName:error:
785 | @see rollbackToSavePointWithName:error:
786 | */
787 |
788 | - (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr;
789 |
790 | /** Release save point
791 |
792 | @param name Name of save point.
793 |
794 | @param outErr A `NSError` object to receive any error object (if any).
795 |
796 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
797 |
798 | @see startSavePointWithName:error:
799 | @see rollbackToSavePointWithName:error:
800 |
801 | */
802 |
803 | - (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr;
804 |
805 | /** Roll back to save point
806 |
807 | @param name Name of save point.
808 | @param outErr A `NSError` object to receive any error object (if any).
809 |
810 | @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
811 |
812 | @see startSavePointWithName:error:
813 | @see releaseSavePointWithName:error:
814 |
815 | */
816 |
817 | - (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr;
818 |
819 | /** Start save point
820 |
821 | @param block Block of code to perform from within save point.
822 |
823 | @return The NSError corresponding to the error, if any. If no error, returns `nil`.
824 |
825 | @see startSavePointWithName:error:
826 | @see releaseSavePointWithName:error:
827 | @see rollbackToSavePointWithName:error:
828 |
829 | */
830 |
831 | - (NSError*)inSavePoint:(void (^)(BOOL *rollback))block;
832 |
833 | #endif
834 |
835 | ///----------------------------
836 | /// @name SQLite library status
837 | ///----------------------------
838 |
839 | /** Test to see if the library is threadsafe
840 |
841 | @return `NO` if and only if SQLite was compiled with mutexing code omitted due to the SQLITE_THREADSAFE compile-time option being set to 0.
842 |
843 | @see [sqlite3_threadsafe()](http://sqlite.org/c3ref/threadsafe.html)
844 | */
845 |
846 | + (BOOL)isSQLiteThreadSafe;
847 |
848 | /** Run-time library version numbers
849 |
850 | @return The sqlite library version string.
851 |
852 | @see [sqlite3_libversion()](http://sqlite.org/c3ref/libversion.html)
853 | */
854 |
855 | + (NSString*)sqliteLibVersion;
856 |
857 |
858 | + (NSString*)FMDBUserVersion;
859 |
860 | + (SInt32)FMDBVersion;
861 |
862 |
863 | ///------------------------
864 | /// @name Make SQL function
865 | ///------------------------
866 |
867 | /** Adds SQL functions or aggregates or to redefine the behavior of existing SQL functions or aggregates.
868 |
869 | For example:
870 |
871 | [queue inDatabase:^(FMDatabase *adb) {
872 |
873 | [adb executeUpdate:@"create table ftest (foo text)"];
874 | [adb executeUpdate:@"insert into ftest values ('hello')"];
875 | [adb executeUpdate:@"insert into ftest values ('hi')"];
876 | [adb executeUpdate:@"insert into ftest values ('not h!')"];
877 | [adb executeUpdate:@"insert into ftest values ('definitely not h!')"];
878 |
879 | [adb makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int aargc, sqlite3_value **aargv) {
880 | if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) {
881 | @autoreleasepool {
882 | const char *c = (const char *)sqlite3_value_text(aargv[0]);
883 | NSString *s = [NSString stringWithUTF8String:c];
884 | sqlite3_result_int(context, [s hasPrefix:@"h"]);
885 | }
886 | }
887 | else {
888 | NSLog(@"Unknown formart for StringStartsWithH (%d) %s:%d", sqlite3_value_type(aargv[0]), __FUNCTION__, __LINE__);
889 | sqlite3_result_null(context);
890 | }
891 | }];
892 |
893 | int rowCount = 0;
894 | FMResultSet *ars = [adb executeQuery:@"select * from ftest where StringStartsWithH(foo)"];
895 | while ([ars next]) {
896 | rowCount++;
897 | NSLog(@"Does %@ start with 'h'?", [rs stringForColumnIndex:0]);
898 | }
899 | FMDBQuickCheck(rowCount == 2);
900 | }];
901 |
902 | @param name Name of function
903 |
904 | @param count Maximum number of parameters
905 |
906 | @param block The block of code for the function
907 |
908 | @see [sqlite3_create_function()](http://sqlite.org/c3ref/create_function.html)
909 | */
910 |
911 | - (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(sqlite3_context *context, int argc, sqlite3_value **argv))block;
912 |
913 |
914 | ///---------------------
915 | /// @name Date formatter
916 | ///---------------------
917 |
918 | /** Generate an `NSDateFormatter` that won't be broken by permutations of timezones or locales.
919 |
920 | Use this method to generate values to set the dateFormat property.
921 |
922 | Example:
923 |
924 | myDB.dateFormat = [FMDatabase storeableDateFormat:@"yyyy-MM-dd HH:mm:ss"];
925 |
926 | @param format A valid NSDateFormatter format string.
927 |
928 | @return A `NSDateFormatter` that can be used for converting dates to strings and vice versa.
929 |
930 | @see hasDateFormatter
931 | @see setDateFormat:
932 | @see dateFromString:
933 | @see stringFromDate:
934 | @see storeableDateFormat:
935 |
936 | @warning Note that `NSDateFormatter` is not thread-safe, so the formatter generated by this method should be assigned to only one FMDB instance and should not be used for other purposes.
937 |
938 | */
939 |
940 | + (NSDateFormatter *)storeableDateFormat:(NSString *)format;
941 |
942 | /** Test whether the database has a date formatter assigned.
943 |
944 | @return `YES` if there is a date formatter; `NO` if not.
945 |
946 | @see hasDateFormatter
947 | @see setDateFormat:
948 | @see dateFromString:
949 | @see stringFromDate:
950 | @see storeableDateFormat:
951 | */
952 |
953 | - (BOOL)hasDateFormatter;
954 |
955 | /** Set to a date formatter to use string dates with sqlite instead of the default UNIX timestamps.
956 |
957 | @param format Set to nil to use UNIX timestamps. Defaults to nil. Should be set using a formatter generated using FMDatabase::storeableDateFormat.
958 |
959 | @see hasDateFormatter
960 | @see setDateFormat:
961 | @see dateFromString:
962 | @see stringFromDate:
963 | @see storeableDateFormat:
964 |
965 | @warning Note there is no direct getter for the `NSDateFormatter`, and you should not use the formatter you pass to FMDB for other purposes, as `NSDateFormatter` is not thread-safe.
966 | */
967 |
968 | - (void)setDateFormat:(NSDateFormatter *)format;
969 |
970 | /** Convert the supplied NSString to NSDate, using the current database formatter.
971 |
972 | @param s `NSString` to convert to `NSDate`.
973 |
974 | @return The `NSDate` object; or `nil` if no formatter is set.
975 |
976 | @see hasDateFormatter
977 | @see setDateFormat:
978 | @see dateFromString:
979 | @see stringFromDate:
980 | @see storeableDateFormat:
981 | */
982 |
983 | - (NSDate *)dateFromString:(NSString *)s;
984 |
985 | /** Convert the supplied NSDate to NSString, using the current database formatter.
986 |
987 | @param date `NSDate` of date to convert to `NSString`.
988 |
989 | @return The `NSString` representation of the date; `nil` if no formatter is set.
990 |
991 | @see hasDateFormatter
992 | @see setDateFormat:
993 | @see dateFromString:
994 | @see stringFromDate:
995 | @see storeableDateFormat:
996 | */
997 |
998 | - (NSString *)stringFromDate:(NSDate *)date;
999 |
1000 | @end
1001 |
1002 |
1003 | /** Objective-C wrapper for `sqlite3_stmt`
1004 |
1005 | This is a wrapper for a SQLite `sqlite3_stmt`. Generally when using FMDB you will not need to interact directly with `FMStatement`, but rather with `` and `` only.
1006 |
1007 | ### See also
1008 |
1009 | - ``
1010 | - ``
1011 | - [`sqlite3_stmt`](http://www.sqlite.org/c3ref/stmt.html)
1012 | */
1013 |
1014 | @interface FMStatement : NSObject {
1015 | sqlite3_stmt *_statement;
1016 | NSString *_query;
1017 | long _useCount;
1018 | BOOL _inUse;
1019 | }
1020 |
1021 | ///-----------------
1022 | /// @name Properties
1023 | ///-----------------
1024 |
1025 | /** Usage count */
1026 |
1027 | @property (atomic, assign) long useCount;
1028 |
1029 | /** SQL statement */
1030 |
1031 | @property (atomic, retain) NSString *query;
1032 |
1033 | /** SQLite sqlite3_stmt
1034 |
1035 | @see [`sqlite3_stmt`](http://www.sqlite.org/c3ref/stmt.html)
1036 | */
1037 |
1038 | @property (atomic, assign) sqlite3_stmt *statement;
1039 |
1040 | /** Indication of whether the statement is in use */
1041 |
1042 | @property (atomic, assign) BOOL inUse;
1043 |
1044 | ///----------------------------
1045 | /// @name Closing and Resetting
1046 | ///----------------------------
1047 |
1048 | /** Close statement */
1049 |
1050 | - (void)close;
1051 |
1052 | /** Reset statement */
1053 |
1054 | - (void)reset;
1055 |
1056 | @end
1057 |
1058 |
--------------------------------------------------------------------------------