{"id":760,"date":"2010-12-09T15:19:26","date_gmt":"2010-12-09T06:19:26","guid":{"rendered":"http:\/\/yamazon.org\/?p=760"},"modified":"2010-12-09T15:19:26","modified_gmt":"2010-12-09T06:19:26","slug":"sqlite%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e3%83%99%e3%83%bc%e3%82%b9%e3%81%8b%e3%82%89%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%8f%96%e3%82%8a%e5%87%ba%e3%81%99","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=760","title":{"rendered":"SQLite\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059"},"content":{"rendered":"<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001SQLite\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5916\u90e8\u3067\u4f5c\u6210\u3057\u3001XCode\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u8aad\u307f\u8fbc\u3093\u3067\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u3001\u304a\u307f\u304f\u3058\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><!--more-->\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u308b\u5358\u7d14\u306a\u3082\u306e\u3067\u3059\u3002SQLite\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059\u3053\u3068\u3092\u8aac\u660e\u3059\u308b\u306e\u304c\u8da3\u65e8\u3067\u3059\u306e\u3067\u3001\u52b9\u7387\u7684\u3067\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u95a2\u9023\u306e\u30e1\u30bd\u30c3\u30c9\u306a\u3069\u306f\u3001\u3059\u3079\u3066\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u51e6\u7406\u3057\u307e\u3059\u3002<\/p>\n<p><strong><span style=\"color: #008000;\">\u4eca\u56de\u306e\u6d41\u308c<\/span><\/strong><\/p>\n<ol>\n<li>SQLite\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u65b0\u898f\u4f5c\u6210\u3059\u308b<\/li>\n<li>\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092XCode\u306b\u53d6\u308a\u8fbc\u3080<\/li>\n<li>iPhone\u4e0a\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u4f5c\u6210<\/li>\n<li>\u53d6\u308a\u8fbc\u3093\u3060\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059<\/li>\n<\/ol>\n<h4>SQLite\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u65b0\u898f\u4f5c\u6210\u3059\u308b<\/h4>\n<p>\u307e\u305a\u3001SQLite\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002Mac\u306e\u30bf\u30fc\u30df\u30ca\u30eb\u4e0a\u304b\u3089\u4f5c\u6210\u3059\u308b\u5834\u5408\u306f\u3001<a href=\"http:\/\/yamazon.org\/iphone-app-develop-tips\/681\">\u3053\u3061\u3089\u306e\u8a18\u4e8b<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u7c21\u5358\u306b\u4f5c\u6210\u3059\u308b\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001GUI\u3067\u64cd\u4f5c\u51fa\u6765\u308b\u30c4\u30fc\u30eb\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u79c1\u304c\u666e\u6bb5\u5229\u7528\u3057\u3066\u3044\u308b\u306e\u306f\u3001<a href=\"http:\/\/yamazon.org\/iphone-app-develop-tips\/tips\/725\">The SQLite Sorcerer<\/a> \u3067\u3059\u3002\u8a73\u7d30\u306f\u3001\u30ea\u30f3\u30af\u5148\u306e\u8a18\u4e8b\u3067\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001SQLite\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u306e\u3067\u3001The SQLite Sorcerer \u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u90e8\u306e\u300cCreate\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-761\" title=\"760-1\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-1-300x226.png\" alt=\"760-1\" width=\"300\" height=\"226\" \/><\/a>\u305d\u306e\u5f8c\u306b\u958b\u304b\u308c\u308b\u300cCreate a new databaase\u300d\u30c0\u30a4\u30a2\u30ed\u30b0\u5185\u306e\u30d5\u30a9\u30eb\u30c0\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u4f5c\u6210\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4fdd\u5b58\u5148\u304a\u3088\u3073\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-762\" title=\"760-2\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-2-300x227.png\" alt=\"760-2\" width=\"300\" height=\"227\" \/><\/a>\u4eca\u56de\u306f\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u306b\u300ctestDB.sqlite\u300d\u3068\u3044\u3046\u540d\u524d\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-763\" title=\"760-3\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-3-300x226.png\" alt=\"760-3\" width=\"300\" height=\"226\" \/><\/a>\u3053\u306e\u969b\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4fdd\u5b58\u5148\u306e\u4e0b\u306b\u3042\u308b\u300cKey\u300d\u306f\u8a2d\u5b9a\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u300cKey\u300d\u3092\u8a2d\u5b9a\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u8a2d\u5b9a\u3057\u305fKey\u3092\u5165\u529b\u3057\u306a\u3044\u3068\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u64cd\u4f5c\u51fa\u6765\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u300cCreate\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3059\u308b\u3068\u3001\u6307\u5b9a\u3057\u305f\u540d\u524d\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u4f5c\u6210\u3055\u308c\u3001\u300ctables\u300d\u3001\u300cviews\u300d\u306a\u3069\u306e\u30a2\u30a4\u30b3\u30f3\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u300ctables\u300d\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3001\u65b0\u898f\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u300cName\u300d\u3001\u300cKey\u300d\u306e\u5165\u529b\u304c\u6c42\u3081\u3089\u308c\u307e\u3059\u306e\u3067\u3001Name \u306b\u306f\u3001\u300cfortune\u300d\u3001Key \u306b\u306f\u300cpk\u300d\u3068\u5165\u529b\u3057\u3001Create \u3057\u307e\u3059\u3002<\/p>\n<p>fortune \u3068\u306f\u904b\u52e2(\u304a\u307f\u304f\u3058)\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<\/p>\n<p>pk \u306f\u30d7\u30e9\u30a4\u30de\u30ea\u30fc\u30ad\u30fc(primary key)\u306e\u7565\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u307e\u3067\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-764 aligncenter\" title=\"760-4\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-4-300x228.png\" alt=\"760-4\" width=\"300\" height=\"228\" \/><\/a><\/p>\n<p>\u53f3\u5074\u306b\u8a2d\u5b9a\u6e08\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u305d\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u4e0a\u90e8\u306b\u3042\u308b\u300cNew Field\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3001\u65b0\u3057\u3044\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a3\u30fc\u30eb\u30c9\u8868\u793a\u90e8\u306e\u4e0b\u306b\u65b0\u898f\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u8a2d\u5b9a\u753b\u9762\u304c\u73fe\u308c\u307e\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3001\u53f3\u5074\u306b\u3042\u308b\u7dd1\u306e\u30d7\u30e9\u30b9\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-765\" title=\"760-5\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-5-300x228.png\" alt=\"760-5\" width=\"300\" height=\"228\" \/><\/a>fortuneList &#8211; \u3053\u3053\u306f\u3001\u5927\u5409\u3001\u4e2d\u5409 \u306a\u3069\u304a\u307f\u304f\u3058\u306e\u4e2d\u8eab\u3092\u767b\u9332\u3059\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3059\u3002<\/p>\n<p>\u540c\u69d8\u306b\u3057\u3066\u3001comment \u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u3053\u306b\u306f\u3001\u304a\u307f\u304f\u3058\u7d50\u679c\u306b\u5bfe\u3059\u308b\u30b3\u30e1\u30f3\u30c8\u3092\u767b\u9332\u3057\u307e\u3059\u3002size \u306f50\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u6b21\u306f\u3001\u30ec\u30b3\u30fc\u30c9\u3092\u767b\u9332\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u753b\u9762\u53f3\u4e0a\u306b\u3042\u308b\u300cData\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\uff08\u5148\u307b\u3069\u30af\u30ea\u30c3\u30af\u3057\u305fField\u30dc\u30bf\u30f3\u306e\u6a2a\uff09\u3001\u300cAdd a record\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u307e\u3059\u3002\u79c1\u306f\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u767b\u9332\u3057\u307e\u3057\u305f\u304c\u3001\u8a73\u7d30\u306f\u304a\u597d\u304d\u306b\u8a2d\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4eca\u56de\u306f\uff13\u3064\u3060\u3051\u767b\u9332\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-766\" title=\"760-6\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-6-300x226.png\" alt=\"760-6\" width=\"300\" height=\"226\" \/><\/a><\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4f5c\u6210\u4f5c\u696d\u306f\u3053\u308c\u3067\u7d42\u4e86\u3067\u3059\u306e\u3067\u3001The SQLite Sorcerer \u3092\u9589\u3058\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306f\u3001XCode\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304b\u3089\u300cView-based Application\u300d\u3092\u9078\u629e\u3057\u307e\u3059\u3002\u540d\u524d\u306f\u300cfortune\u300d\u306b\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-769\" title=\"760-7\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-7-300x245.png\" alt=\"760-7\" width=\"300\" height=\"245\" \/><\/a><\/p>\n<h4>\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092XCode\u306b\u53d6\u308a\u8fbc\u3080<\/h4>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u4f5c\u6210\u3055\u308c\u305f\u3089\u3001Resource\u30d5\u30a9\u30eb\u30c0\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3001\u65e2\u5b58\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8ffd\u52a0\u304b\u3089\u3001\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\u305d\u306e\u969b\u3001\u8868\u793a\u3055\u308c\u308b\u30c0\u30a4\u30a2\u30ed\u30b0\u5185\u306e\u300c\u30c7\u30b9\u30c6\u30a3\u30cd\u30fc\u30b7\u30e7\u30f3&#8230;\u300d\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u3001\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>iPhone\u4e0a\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u4f5c\u6210<\/h4>\n<p>\u307e\u305a\u3001Interface Builder \u3092\u8d77\u52d5\u3057\u3066\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>XCode\u5185\u306efortuneViewControllerxib\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001Interface Builder\u304c\u8d77\u52d5\u3057\u307e\u3059\u3002Interface Builder \u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"http:\/\/yamazon.org\/iphone-app-develop-tips\/601\">\u3053\u306e\u8fba<\/a>\u3067\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u30e9\u30d9\u30eb\u3001\u30dc\u30bf\u30f3\u3092\u305d\u308c\u305e\u308c\u914d\u7f6e\u3057\u307e\u3057\u305f\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30e9\u30d9\u30eb\uff13\u3064\u3068\u30dc\u30bf\u30f3\u3092\u914d\u7f6e\u3057\u3001\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-772\" title=\"760-8\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-8-190x300.png\" alt=\"760-8\" width=\"190\" height=\"300\" \/><\/a><\/p>\n<h4>\u53d6\u308a\u8fbc\u3093\u3060\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059<\/h4>\n<p>XCode\u306b\u623b\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u64cd\u4f5c\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u3001\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002Frameworks\u30d5\u30a9\u30eb\u30c0\u3092\u53f3\u30af\u30ea\u30c3\u30af\u3057\u3001\u8ffd\u52a0 \uff1e \u65e2\u5b58\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002\u52d5\u7684\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e2d\u306e\u300clibsqlite3.0.dylib\u300d\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u3001<strong>fortuneViewController.h<\/strong> \u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<blockquote>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #78492a;\">#import <\/span>&lt;UIKit\/UIKit.h&gt;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #78492a;\">#import <\/span>&lt;sqlite3.h&gt;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"color: #bb2da2;\">@interface<\/span> fortuneViewController : UIViewController {<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4e8187;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #bb2da2;\">IBOutlet<\/span><span style=\"color: #000000;\"> <\/span><span style=\"color: #703daa;\">UILabel<\/span><span style=\"color: #000000;\"> *<\/span>fortuneResult<span style=\"color: #000000;\">;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>IBOutlet<span style=\"color: #000000;\"> <\/span><span style=\"color: #703daa;\">UILabel<\/span><span style=\"color: #000000;\"> *<\/span><span style=\"color: #4e8187;\">comment<\/span><span style=\"color: #000000;\">;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>IBOutlet<span style=\"color: #000000;\"> <\/span><span style=\"color: #703daa;\">UILabel<\/span><span style=\"color: #000000;\"> *<\/span><span style=\"color: #4e8187;\">navi<\/span><span style=\"color: #000000;\">;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\">}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\">@property<span style=\"color: #000000;\">(<\/span>nonatomic<span style=\"color: #000000;\">,<\/span>retain<span style=\"color: #000000;\">) <\/span>IBOutlet<span style=\"color: #000000;\"> UILabel *fortuneResult;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\">@property<span style=\"color: #000000;\">(<\/span>nonatomic<span style=\"color: #000000;\">,<\/span>retain<span style=\"color: #000000;\">) <\/span>IBOutlet<span style=\"color: #000000;\"> UILabel *comment;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\">@property<span style=\"color: #000000;\">(<\/span>nonatomic<span style=\"color: #000000;\">,<\/span>retain<span style=\"color: #000000;\">) <\/span>IBOutlet<span style=\"color: #000000;\"> UILabel *navi;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\">-(<span style=\"color: #bb2da2;\">IBAction<\/span>) submit:(<span style=\"color: #bb2da2;\">id<\/span>) sender;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\">@end<\/p>\n<\/blockquote>\n<p>\u6b21\u306b\u3001<strong>fortuneViewController.m<\/strong> \u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001\u30b3\u30fc\u30c9\u5185\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<blockquote>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #78492a;\">#import <\/span>&#8220;fortuneViewController.h&#8221;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"color: #bb2da2;\">@implementation<\/span> fortuneViewController<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"color: #bb2da2;\">@synthesize<\/span> fortuneResult,comment,navi;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\">-(<span style=\"color: #bb2da2;\">IBAction<\/span>) submit:(<span style=\"color: #bb2da2;\">id<\/span>) sender{<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px\/normal Menlo; \"><span style=\"color: #008000;\">\/\/\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u308b\u3068\u300c\u4eca\u65e5\u306e\u904b\u52e2\u306f&#8230;\u300d\u3068\u8868\u793a\u3055\u308c\u307e\u3059<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #4e8187;\">navi<\/span><span style=\"color: #000000;\">.<\/span><span style=\"color: #703daa;\">text<\/span><span style=\"color: #000000;\"> = <\/span>@&#8221;<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u4eca\u65e5\u306e\u904b\u52e2\u306f<\/span>&#8230;&#8221;<span style=\"color: #000000;\">;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"color: #008000;\">\/\/\u30dc\u30bf\u30f3\u306e\u30af\u30ea\u30c3\u30af\u304b\u3089\u300c0.5\u300d\u79d2\u5f8c\u306b\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u307e\u3059<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span>[<\/span><span style=\"color: #703daa;\">NSThread<\/span><span style=\"color: #000000;\"> <\/span>sleepForTimeInterval<span style=\"color: #000000;\">:<\/span><span style=\"color: #252bd8;\">0.5<\/span><span style=\"color: #000000;\">];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #703daa;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>sqlite3<span style=\"color: #000000;\">* db;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">NSString<\/span>* work_path;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">NSString<\/span>* database_filename;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">NSString<\/span>* database_path;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">NSString<\/span>* template_path;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>\/\/ <span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u3092\u3053\u3053\u3067\u306f<\/span> &#8220;testDB.sqlite&#8221; <span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u3068\u3057\u307e\u3059\u3002<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>database_filename = <span style=\"color: #d12e1b;\">@&#8221;testDB.sqlite&#8221;<\/span>;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306b\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\u30fc\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span>work_path = [<\/span>NSSearchPathForDirectoriesInDomains<span style=\"color: #000000;\">(<\/span>NSDocumentDirectory<span style=\"color: #000000;\">, <\/span>NSUserDomainMask<span style=\"color: #000000;\">, <\/span><span style=\"color: #bb2da2;\">YES<\/span><span style=\"color: #000000;\">) <\/span>objectAtIndex<span style=\"color: #000000;\">:<\/span><span style=\"color: #252bd8;\">0<\/span><span style=\"color: #000000;\">];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>database_path = [<span style=\"color: #703daa;\">NSString<\/span> <span style=\"color: #3d1e81;\">stringWithFormat<\/span>:<span style=\"color: #d12e1b;\">@&#8221;%@\/%@&#8221;<\/span>, work_path, database_filename];<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #703daa;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>NSFileManager<span style=\"color: #000000;\">* manager = [<\/span>NSFileManager<span style=\"color: #000000;\"> <\/span><span style=\"color: #3d1e81;\">defaultManager<\/span><span style=\"color: #000000;\">];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">if<\/span> (![manager <span style=\"color: #3d1e81;\">fileExistsAtPath<\/span>:database_path])<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>{<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">NSError<\/span>* error = <span style=\"color: #bb2da2;\">nil<\/span>;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8907\u88fd\u5143\u3092\u30d0\u30f3\u30c9\u30eb\u304b\u3089\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span>template_path = [[[<\/span><span style=\"color: #703daa;\">NSBundle<\/span><span style=\"color: #000000;\"> <\/span>mainBundle<span style=\"color: #000000;\">] <\/span>resourcePath<span style=\"color: #000000;\">] <\/span>stringByAppendingPathComponent<span style=\"color: #000000;\">:database_filename];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u30d0\u30f3\u30c9\u30eb\u304b\u3089\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">if<\/span> (![manager <span style=\"color: #3d1e81;\">copyItemAtPath<\/span>:template_path <span style=\"color: #3d1e81;\">toPath<\/span>:database_path <span style=\"color: #3d1e81;\">error<\/span>:&amp;error])<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>{<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30b3\u30d4\u30fc\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306e\u51e6\u7406\u3067\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;DB<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u8aad\u307f\u8fbc\u307f\u5931\u6557<\/span>&#8220;<span style=\"color: #000000;\">);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>} <span style=\"color: #bb2da2;\">else<\/span> {<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;DB<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u8aad\u307f\u8fbc\u307f\u6210\u529f<\/span>&#8220;<span style=\"color: #000000;\">);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<span style=\"color: #bb2da2;\">else<\/span> {<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;DB<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u767a\u898b<\/span>&#8220;<span style=\"color: #000000;\">);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u6587\u66f8\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u7528\u610f\u3055\u308c\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">if<\/span> (<span style=\"color: #3d1e81;\">sqlite3_open<\/span>([database_path <span style=\"color: #3d1e81;\">UTF8String<\/span>], &amp;db) == <span style=\"color: #78492a;\">SQLITE_OK<\/span>)<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>{<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ <\/span>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u3092<span style=\"font: 11.0px Menlo;\"> SQLite <\/span>\u3067\u958b\u304f\u3053\u3068\u306b\u6210\u529f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;DB<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u30aa\u30fc\u30d7\u30f3\u6210\u529f<\/span>:%d&#8221;<span style=\"color: #000000;\">,db);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #703daa;\">sqlite3_stmt<\/span> *statement;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"><span style=\"color: #008000;\">\/\/\u30e9\u30f3\u30c0\u30e0\u306b\u7d50\u679c\u3092\u53d6\u308a\u51fa\u3059\u305f\u3081\u306e\u8a2d\u5b9a\u3067\u3059\u3002<\/span><\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"><span style=\"color: #008000;\">\/\/\uff10\u301c\uff13\u306e\uff14\u3064\u306e\u6570\u5b57\u304c\u30e9\u30f3\u30c0\u30e0\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/span><\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>srand<span style=\"color: #000000;\">(<\/span>time<span style=\"color: #000000;\">(<\/span><span style=\"color: #bb2da2;\">nil<\/span><span style=\"color: #000000;\">));<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">int<\/span> rnd = <span style=\"color: #3d1e81;\">rand<\/span>() % <span style=\"color: #252bd8;\">4<\/span>;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #3d1e81;\">NSLog<\/span>(<span style=\"color: #d12e1b;\">@&#8221;%d&#8221;<\/span>,rnd);<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">if<\/span>(rnd == <span style=\"color: #252bd8;\">0<\/span>){<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>rnd = <span style=\"color: #252bd8;\">2<\/span>;<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #bb2da2;\">const<\/span><span style=\"color: #000000;\"> <\/span><span style=\"color: #bb2da2;\">char<\/span><span style=\"color: #000000;\"> *sql = <\/span>&#8220;SELECT fortuneList,comment FROM fortune WHERE pk = ?&#8221;<span style=\"color: #000000;\">;<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Hiragino Kaku Gothic ProN'; color: #008400;\"><span style=\"font: 11.0px Menlo; color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"font: 11.0px Menlo;\">\/\/ SQL <\/span>\u6587\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #bb2da2;\">if<\/span> (<span style=\"color: #3d1e81;\">sqlite3_prepare_v2<\/span>(db, sql, &#8211;<span style=\"color: #252bd8;\">1<\/span>, &amp;statement, <span style=\"color: #bb2da2;\">NULL<\/span>) != <span style=\"color: #78492a;\">SQLITE_OK<\/span>)<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>{<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;error message &#8216;%s&#8217;.&#8221;<span style=\"color: #000000;\">, <\/span><span style=\"color: #3d1e81;\">sqlite3_errmsg<\/span><span style=\"color: #000000;\">(db));<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bb2da2;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span>}<\/span>else<span style=\"color: #000000;\">{<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #3d1e81;\">NSLog<\/span><span style=\"color: #000000;\">(<\/span>@&#8221;SQL<span style=\"font: 11.0px 'Hiragino Kaku Gothic ProN';\">\u30b3\u30f3\u30d1\u30a4\u30eb\u6210\u529f<\/span>&#8220;<span style=\"color: #000000;\">);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12e1b;\"><span style=\"color: #000000;\"><span style=\"font: normal normal normal 11px\/normal Menlo;\"><span style=\"color: #008000;\">\/\/ rnd \u306e\u5024\u304c\u3001\u4e0a\u306eSQL\u6587\u306e\u201d\uff1f\u201d\u306b\u633f\u5165\u3055\u308c\u307e\u3059\u3002<\/span><\/span><\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #3d1e81;\">sqlite3_bind_int<\/span>(statement, <span style=\"color: #252bd8;\">1<\/span>, rnd);<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span><span style=\"color: #3d1e81;\">sqlite3_step<\/span>(statement);<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"><span style=\"color: #008000;\">\/\/sqlite3_column_text<\/span><span style=\"color: #008000;\">(statement, <\/span><span style=\"color: #008000;\">0<\/span><span style=\"color: #008000;\">) \u3067fortuneList \u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<\/span><\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #4e8187;\">fortuneResult<\/span><span style=\"color: #000000;\">.<\/span><span style=\"color: #703daa;\">text<\/span><span style=\"color: #000000;\"> =<span style=\"white-space: pre;\"> <\/span>[<\/span><span style=\"color: #703daa;\">NSString<\/span><span style=\"color: #000000;\"> <\/span>stringWithUTF8String<span style=\"color: #000000;\">\ud83d\ude41<\/span><span style=\"color: #bb2da2;\">char<\/span><span style=\"color: #000000;\"> *)<\/span>sqlite3_column_text<span style=\"color: #000000;\">(statement, <\/span><span style=\"color: #252bd8;\">0<\/span><span style=\"color: #000000; \">)];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"><span style=\"color: #008000;\">\/\/sqlite3_column_text<\/span><span style=\"color: #008000;\">(statement, 1<\/span><\/span><span style=\"color: #008000; white-space: pre;\">) \u3067comment \u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span><span style=\"color: #4e8187;\">comment<\/span><span style=\"color: #000000;\">.<\/span><span style=\"color: #703daa;\">text<\/span><span style=\"color: #000000;\"> =<span style=\"white-space: pre;\"> <\/span>[<\/span><span style=\"color: #703daa;\">NSString<\/span><span style=\"color: #000000;\"> <\/span>stringWithUTF8String<span style=\"color: #000000;\">\ud83d\ude41<\/span><span style=\"color: #bb2da2;\">char<\/span><span style=\"color: #000000;\"> *)<\/span>sqlite3_column_text<span style=\"color: #000000;\">(statement, <\/span><span style=\"color: #252bd8;\">1<\/span><span style=\"color: #000000;\">)];<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\"><span style=\"white-space: pre;\"> <\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"><span style=\"color: #008000;\">\/\/prepare\u6e08\u307fSQL\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3092\u5ec3\u68c4\u3057\u307e\u3059\u3002<\/span><\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #000000;\"><span style=\"white-space: pre;\"> <\/span><\/span>sqlite3_finalize<span style=\"color: #000000;\">(statement);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\"><span style=\"color: #008000;\">\/\/\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u9589\u3058\u307e\u3059\u3002<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #3d1e81;\">sqlite3_close<span style=\"color: #000000;\">(db);<\/span><\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\"><span style=\"white-space: pre;\"> <\/span>}<\/p>\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;\">\n<p style=\"margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;\">}<\/p>\n<\/blockquote>\n<p>\u3053\u308c\u3067\u30d3\u30eb\u30c9\uff06\u5b9f\u884c\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u4ee5\u4e0b\u306e\u753b\u50cf\u306e\u3088\u3046\u306b\u304a\u307f\u304f\u3058\u306e\u7d50\u679c\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u8868\u793a\u3055\u308c\u305f\u3089\u5b8c\u6210\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-774\" title=\"760-9\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-9-159x300.png\" alt=\"760-9\" width=\"159\" height=\"300\" \/><\/a><\/p>\n<p>\u5c11\u3057\u3001\u5bc2\u3057\u3044\u306e\u3067\u3001\u80cc\u666f\u306e\u753b\u50cf\u3092\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\u3002<a href=\"http:\/\/yamazon.org\/iphone-app-develop-tips\/tips\/730\">\u80cc\u666f\u306e\u8a2d\u5b9a\u65b9\u6cd5\u306f\u3053\u3061\u3089<\/a>\u3067\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-775\" title=\"760-10\" src=\"http:\/\/yamazon.org\/wp-content\/uploads\/2010\/12\/760-10-158x300.png\" alt=\"760-10\" width=\"158\" height=\"300\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u306f\u3001SQLite\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u5916\u90e8\u3067\u4f5c\u6210\u3057\u3001XCod&#8230;<\/p>\n","protected":false},"author":1,"featured_media":761,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-old-blog"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=760"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/760\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}