├── .gitignore ├── InternBookmark.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── InternBookmark.xcworkspace └── contents.xcworkspacedata ├── InternBookmark ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── Classes │ ├── Controllers │ │ ├── BookmarkViewController.swift │ │ ├── BookmarksViewController.swift │ │ └── LoginViewController.swift │ ├── InternBookmark-Bridging-Header.h │ ├── Models │ │ ├── BookmarkManager.swift │ │ ├── DataModels │ │ │ ├── Bookmark.swift │ │ │ ├── Entry.swift │ │ │ └── User.swift │ │ └── InternBookmarkAPIClient.swift │ └── Utilities │ │ ├── NSDateFormatter+MySQL.swift │ │ └── UIAlertController+NSError.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json └── Info.plist ├── InternBookmarkTests ├── Info.plist └── InternBookmarkTests.swift ├── Podfile ├── Podfile.lock └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # CocoaPods 23 | Pods 24 | -------------------------------------------------------------------------------- /InternBookmark.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0E054525198DEA5C009E3EBE /* BookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054524198DEA5C009E3EBE /* BookmarksViewController.swift */; }; 11 | 0E054527198DF850009E3EBE /* BookmarkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054526198DF850009E3EBE /* BookmarkManager.swift */; }; 12 | 0E054529198DFE0C009E3EBE /* InternBookmarkAPIClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054528198DFE0C009E3EBE /* InternBookmarkAPIClient.swift */; }; 13 | 0E054530198E5D50009E3EBE /* Bookmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05452F198E5D50009E3EBE /* Bookmark.swift */; }; 14 | 0E054532198E5EFF009E3EBE /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054531198E5EFF009E3EBE /* User.swift */; }; 15 | 0E054535198E6799009E3EBE /* NSDateFormatter+MySQL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054534198E6799009E3EBE /* NSDateFormatter+MySQL.swift */; }; 16 | 0E054537198E6A95009E3EBE /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E054536198E6A95009E3EBE /* Entry.swift */; }; 17 | 0EB4AEBC199119E300E63CFF /* UIAlertController+NSError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB4AEBB199119E300E63CFF /* UIAlertController+NSError.swift */; }; 18 | 0ED64DFF198DE3C4001D7680 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED64DFE198DE3C4001D7680 /* AppDelegate.swift */; }; 19 | 0ED64E04198DE3C4001D7680 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0ED64E02198DE3C4001D7680 /* Main.storyboard */; }; 20 | 0ED64E06198DE3C4001D7680 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0ED64E05198DE3C4001D7680 /* Images.xcassets */; }; 21 | 0ED64E12198DE3C4001D7680 /* InternBookmarkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED64E11198DE3C4001D7680 /* InternBookmarkTests.swift */; }; 22 | 0EDA7E5C198FB7F40003E8C5 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDA7E5B198FB7F40003E8C5 /* BookmarkViewController.swift */; }; 23 | 0EDA7E5E198FBA570003E8C5 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDA7E5D198FBA570003E8C5 /* LoginViewController.swift */; }; 24 | D2FDB33E04524E99A85960FA /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4EFC83500B46298394F0E8 /* libPods.a */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 0ED64E0C198DE3C4001D7680 /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 0ED64DF1198DE3C4001D7680 /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 0ED64DF8198DE3C4001D7680; 33 | remoteInfo = InternBookmark; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 0E054524198DEA5C009E3EBE /* BookmarksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarksViewController.swift; sourceTree = ""; }; 39 | 0E054526198DF850009E3EBE /* BookmarkManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkManager.swift; sourceTree = ""; }; 40 | 0E054528198DFE0C009E3EBE /* InternBookmarkAPIClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InternBookmarkAPIClient.swift; sourceTree = ""; }; 41 | 0E05452F198E5D50009E3EBE /* Bookmark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bookmark.swift; sourceTree = ""; }; 42 | 0E054531198E5EFF009E3EBE /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 43 | 0E054534198E6799009E3EBE /* NSDateFormatter+MySQL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSDateFormatter+MySQL.swift"; sourceTree = ""; }; 44 | 0E054536198E6A95009E3EBE /* Entry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entry.swift; sourceTree = ""; }; 45 | 0EB4AEBB199119E300E63CFF /* UIAlertController+NSError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIAlertController+NSError.swift"; sourceTree = ""; }; 46 | 0ED64DF9198DE3C4001D7680 /* InternBookmark.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InternBookmark.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 0ED64DFD198DE3C4001D7680 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 0ED64DFE198DE3C4001D7680 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = ../AppDelegate.swift; sourceTree = ""; }; 49 | 0ED64E03198DE3C4001D7680 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 0ED64E05198DE3C4001D7680 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 51 | 0ED64E0B198DE3C4001D7680 /* InternBookmarkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InternBookmarkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | 0ED64E10198DE3C4001D7680 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 0ED64E11198DE3C4001D7680 /* InternBookmarkTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternBookmarkTests.swift; sourceTree = ""; }; 54 | 0EDA7E5B198FB7F40003E8C5 /* BookmarkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = ""; }; 55 | 0EDA7E5D198FBA570003E8C5 /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 56 | 0EEBEFE21A89BD74001729FB /* InternBookmark-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "InternBookmark-Bridging-Header.h"; sourceTree = ""; }; 57 | 3E4EFC83500B46298394F0E8 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | CF75C3A00E514AF99D611AE9 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 0ED64DF6198DE3C4001D7680 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | D2FDB33E04524E99A85960FA /* libPods.a in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 0ED64E08198DE3C4001D7680 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXFrameworksBuildPhase section */ 78 | 79 | /* Begin PBXGroup section */ 80 | 0E054521198DE997009E3EBE /* Classes */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 0EEBEFE21A89BD74001729FB /* InternBookmark-Bridging-Header.h */, 84 | 0E054533198E6746009E3EBE /* Utilities */, 85 | 0E054523198DEA1A009E3EBE /* Models */, 86 | 0E054522198DE9D9009E3EBE /* Controllers */, 87 | 0ED64DFE198DE3C4001D7680 /* AppDelegate.swift */, 88 | ); 89 | path = Classes; 90 | sourceTree = ""; 91 | }; 92 | 0E054522198DE9D9009E3EBE /* Controllers */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 0E054524198DEA5C009E3EBE /* BookmarksViewController.swift */, 96 | 0EDA7E5B198FB7F40003E8C5 /* BookmarkViewController.swift */, 97 | 0EDA7E5D198FBA570003E8C5 /* LoginViewController.swift */, 98 | ); 99 | path = Controllers; 100 | sourceTree = ""; 101 | }; 102 | 0E054523198DEA1A009E3EBE /* Models */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 0E05452E198E5D11009E3EBE /* Data Models */, 106 | 0E054526198DF850009E3EBE /* BookmarkManager.swift */, 107 | 0E054528198DFE0C009E3EBE /* InternBookmarkAPIClient.swift */, 108 | ); 109 | path = Models; 110 | sourceTree = ""; 111 | }; 112 | 0E05452E198E5D11009E3EBE /* Data Models */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 0E05452F198E5D50009E3EBE /* Bookmark.swift */, 116 | 0E054531198E5EFF009E3EBE /* User.swift */, 117 | 0E054536198E6A95009E3EBE /* Entry.swift */, 118 | ); 119 | name = "Data Models"; 120 | path = DataModels; 121 | sourceTree = ""; 122 | }; 123 | 0E054533198E6746009E3EBE /* Utilities */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 0E054534198E6799009E3EBE /* NSDateFormatter+MySQL.swift */, 127 | 0EB4AEBB199119E300E63CFF /* UIAlertController+NSError.swift */, 128 | ); 129 | path = Utilities; 130 | sourceTree = ""; 131 | }; 132 | 0ED64DF0198DE3C4001D7680 = { 133 | isa = PBXGroup; 134 | children = ( 135 | 0ED64DFB198DE3C4001D7680 /* InternBookmark */, 136 | 0ED64E0E198DE3C4001D7680 /* InternBookmarkTests */, 137 | 0ED64DFA198DE3C4001D7680 /* Products */, 138 | CF75C3A00E514AF99D611AE9 /* Pods.xcconfig */, 139 | 88D92883F84C432299D60329 /* Frameworks */, 140 | ); 141 | sourceTree = ""; 142 | }; 143 | 0ED64DFA198DE3C4001D7680 /* Products */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 0ED64DF9198DE3C4001D7680 /* InternBookmark.app */, 147 | 0ED64E0B198DE3C4001D7680 /* InternBookmarkTests.xctest */, 148 | ); 149 | name = Products; 150 | sourceTree = ""; 151 | }; 152 | 0ED64DFB198DE3C4001D7680 /* InternBookmark */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 0E054521198DE997009E3EBE /* Classes */, 156 | 0ED64E02198DE3C4001D7680 /* Main.storyboard */, 157 | 0ED64E05198DE3C4001D7680 /* Images.xcassets */, 158 | 0ED64DFC198DE3C4001D7680 /* Supporting Files */, 159 | ); 160 | path = InternBookmark; 161 | sourceTree = ""; 162 | }; 163 | 0ED64DFC198DE3C4001D7680 /* Supporting Files */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 0ED64DFD198DE3C4001D7680 /* Info.plist */, 167 | ); 168 | name = "Supporting Files"; 169 | sourceTree = ""; 170 | }; 171 | 0ED64E0E198DE3C4001D7680 /* InternBookmarkTests */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | 0ED64E11198DE3C4001D7680 /* InternBookmarkTests.swift */, 175 | 0ED64E0F198DE3C4001D7680 /* Supporting Files */, 176 | ); 177 | path = InternBookmarkTests; 178 | sourceTree = ""; 179 | }; 180 | 0ED64E0F198DE3C4001D7680 /* Supporting Files */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 0ED64E10198DE3C4001D7680 /* Info.plist */, 184 | ); 185 | name = "Supporting Files"; 186 | sourceTree = ""; 187 | }; 188 | 88D92883F84C432299D60329 /* Frameworks */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 3E4EFC83500B46298394F0E8 /* libPods.a */, 192 | ); 193 | name = Frameworks; 194 | sourceTree = ""; 195 | }; 196 | /* End PBXGroup section */ 197 | 198 | /* Begin PBXNativeTarget section */ 199 | 0ED64DF8198DE3C4001D7680 /* InternBookmark */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = 0ED64E15198DE3C4001D7680 /* Build configuration list for PBXNativeTarget "InternBookmark" */; 202 | buildPhases = ( 203 | FDD39B377BB44A559DE84378 /* Check Pods Manifest.lock */, 204 | 0ED64DF5198DE3C4001D7680 /* Sources */, 205 | 0ED64DF6198DE3C4001D7680 /* Frameworks */, 206 | 0ED64DF7198DE3C4001D7680 /* Resources */, 207 | 8E5F99DA6D5645E797E8867D /* Copy Pods Resources */, 208 | ); 209 | buildRules = ( 210 | ); 211 | dependencies = ( 212 | ); 213 | name = InternBookmark; 214 | productName = InternBookmark; 215 | productReference = 0ED64DF9198DE3C4001D7680 /* InternBookmark.app */; 216 | productType = "com.apple.product-type.application"; 217 | }; 218 | 0ED64E0A198DE3C4001D7680 /* InternBookmarkTests */ = { 219 | isa = PBXNativeTarget; 220 | buildConfigurationList = 0ED64E18198DE3C4001D7680 /* Build configuration list for PBXNativeTarget "InternBookmarkTests" */; 221 | buildPhases = ( 222 | 0ED64E07198DE3C4001D7680 /* Sources */, 223 | 0ED64E08198DE3C4001D7680 /* Frameworks */, 224 | 0ED64E09198DE3C4001D7680 /* Resources */, 225 | ); 226 | buildRules = ( 227 | ); 228 | dependencies = ( 229 | 0ED64E0D198DE3C4001D7680 /* PBXTargetDependency */, 230 | ); 231 | name = InternBookmarkTests; 232 | productName = InternBookmarkTests; 233 | productReference = 0ED64E0B198DE3C4001D7680 /* InternBookmarkTests.xctest */; 234 | productType = "com.apple.product-type.bundle.unit-test"; 235 | }; 236 | /* End PBXNativeTarget section */ 237 | 238 | /* Begin PBXProject section */ 239 | 0ED64DF1198DE3C4001D7680 /* Project object */ = { 240 | isa = PBXProject; 241 | attributes = { 242 | LastUpgradeCheck = 0600; 243 | ORGANIZATIONNAME = "Hatena Inc."; 244 | TargetAttributes = { 245 | 0ED64DF8198DE3C4001D7680 = { 246 | CreatedOnToolsVersion = 6.0; 247 | }; 248 | 0ED64E0A198DE3C4001D7680 = { 249 | CreatedOnToolsVersion = 6.0; 250 | TestTargetID = 0ED64DF8198DE3C4001D7680; 251 | }; 252 | }; 253 | }; 254 | buildConfigurationList = 0ED64DF4198DE3C4001D7680 /* Build configuration list for PBXProject "InternBookmark" */; 255 | compatibilityVersion = "Xcode 3.2"; 256 | developmentRegion = English; 257 | hasScannedForEncodings = 0; 258 | knownRegions = ( 259 | en, 260 | Base, 261 | ); 262 | mainGroup = 0ED64DF0198DE3C4001D7680; 263 | productRefGroup = 0ED64DFA198DE3C4001D7680 /* Products */; 264 | projectDirPath = ""; 265 | projectRoot = ""; 266 | targets = ( 267 | 0ED64DF8198DE3C4001D7680 /* InternBookmark */, 268 | 0ED64E0A198DE3C4001D7680 /* InternBookmarkTests */, 269 | ); 270 | }; 271 | /* End PBXProject section */ 272 | 273 | /* Begin PBXResourcesBuildPhase section */ 274 | 0ED64DF7198DE3C4001D7680 /* Resources */ = { 275 | isa = PBXResourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | 0ED64E04198DE3C4001D7680 /* Main.storyboard in Resources */, 279 | 0ED64E06198DE3C4001D7680 /* Images.xcassets in Resources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | 0ED64E09198DE3C4001D7680 /* Resources */ = { 284 | isa = PBXResourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXResourcesBuildPhase section */ 291 | 292 | /* Begin PBXShellScriptBuildPhase section */ 293 | 8E5F99DA6D5645E797E8867D /* Copy Pods Resources */ = { 294 | isa = PBXShellScriptBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | ); 298 | inputPaths = ( 299 | ); 300 | name = "Copy Pods Resources"; 301 | outputPaths = ( 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | shellPath = /bin/sh; 305 | shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; 306 | showEnvVarsInLog = 0; 307 | }; 308 | FDD39B377BB44A559DE84378 /* Check Pods Manifest.lock */ = { 309 | isa = PBXShellScriptBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | ); 313 | inputPaths = ( 314 | ); 315 | name = "Check Pods Manifest.lock"; 316 | outputPaths = ( 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | shellPath = /bin/sh; 320 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 321 | showEnvVarsInLog = 0; 322 | }; 323 | /* End PBXShellScriptBuildPhase section */ 324 | 325 | /* Begin PBXSourcesBuildPhase section */ 326 | 0ED64DF5198DE3C4001D7680 /* Sources */ = { 327 | isa = PBXSourcesBuildPhase; 328 | buildActionMask = 2147483647; 329 | files = ( 330 | 0EB4AEBC199119E300E63CFF /* UIAlertController+NSError.swift in Sources */, 331 | 0E054537198E6A95009E3EBE /* Entry.swift in Sources */, 332 | 0E054530198E5D50009E3EBE /* Bookmark.swift in Sources */, 333 | 0E054527198DF850009E3EBE /* BookmarkManager.swift in Sources */, 334 | 0E054535198E6799009E3EBE /* NSDateFormatter+MySQL.swift in Sources */, 335 | 0E054532198E5EFF009E3EBE /* User.swift in Sources */, 336 | 0E054525198DEA5C009E3EBE /* BookmarksViewController.swift in Sources */, 337 | 0ED64DFF198DE3C4001D7680 /* AppDelegate.swift in Sources */, 338 | 0EDA7E5C198FB7F40003E8C5 /* BookmarkViewController.swift in Sources */, 339 | 0EDA7E5E198FBA570003E8C5 /* LoginViewController.swift in Sources */, 340 | 0E054529198DFE0C009E3EBE /* InternBookmarkAPIClient.swift in Sources */, 341 | ); 342 | runOnlyForDeploymentPostprocessing = 0; 343 | }; 344 | 0ED64E07198DE3C4001D7680 /* Sources */ = { 345 | isa = PBXSourcesBuildPhase; 346 | buildActionMask = 2147483647; 347 | files = ( 348 | 0ED64E12198DE3C4001D7680 /* InternBookmarkTests.swift in Sources */, 349 | ); 350 | runOnlyForDeploymentPostprocessing = 0; 351 | }; 352 | /* End PBXSourcesBuildPhase section */ 353 | 354 | /* Begin PBXTargetDependency section */ 355 | 0ED64E0D198DE3C4001D7680 /* PBXTargetDependency */ = { 356 | isa = PBXTargetDependency; 357 | target = 0ED64DF8198DE3C4001D7680 /* InternBookmark */; 358 | targetProxy = 0ED64E0C198DE3C4001D7680 /* PBXContainerItemProxy */; 359 | }; 360 | /* End PBXTargetDependency section */ 361 | 362 | /* Begin PBXVariantGroup section */ 363 | 0ED64E02198DE3C4001D7680 /* Main.storyboard */ = { 364 | isa = PBXVariantGroup; 365 | children = ( 366 | 0ED64E03198DE3C4001D7680 /* Base */, 367 | ); 368 | name = Main.storyboard; 369 | sourceTree = ""; 370 | }; 371 | /* End PBXVariantGroup section */ 372 | 373 | /* Begin XCBuildConfiguration section */ 374 | 0ED64E13198DE3C4001D7680 /* Debug */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ALWAYS_SEARCH_USER_PATHS = NO; 378 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 379 | CLANG_CXX_LIBRARY = "libc++"; 380 | CLANG_ENABLE_MODULES = YES; 381 | CLANG_ENABLE_OBJC_ARC = YES; 382 | CLANG_WARN_BOOL_CONVERSION = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 385 | CLANG_WARN_EMPTY_BODY = YES; 386 | CLANG_WARN_ENUM_CONVERSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN_UNREACHABLE_CODE = YES; 390 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 391 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 392 | COPY_PHASE_STRIP = NO; 393 | ENABLE_STRICT_OBJC_MSGSEND = YES; 394 | GCC_C_LANGUAGE_STANDARD = gnu99; 395 | GCC_DYNAMIC_NO_PIC = NO; 396 | GCC_OPTIMIZATION_LEVEL = 0; 397 | GCC_PREPROCESSOR_DEFINITIONS = ( 398 | "DEBUG=1", 399 | "$(inherited)", 400 | ); 401 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 402 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 403 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 404 | GCC_WARN_UNDECLARED_SELECTOR = YES; 405 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 406 | GCC_WARN_UNUSED_FUNCTION = YES; 407 | GCC_WARN_UNUSED_VARIABLE = YES; 408 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 409 | MTL_ENABLE_DEBUG_INFO = YES; 410 | ONLY_ACTIVE_ARCH = YES; 411 | SDKROOT = iphoneos; 412 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 413 | }; 414 | name = Debug; 415 | }; 416 | 0ED64E14198DE3C4001D7680 /* Release */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ALWAYS_SEARCH_USER_PATHS = NO; 420 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 421 | CLANG_CXX_LIBRARY = "libc++"; 422 | CLANG_ENABLE_MODULES = YES; 423 | CLANG_ENABLE_OBJC_ARC = YES; 424 | CLANG_WARN_BOOL_CONVERSION = YES; 425 | CLANG_WARN_CONSTANT_CONVERSION = YES; 426 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INT_CONVERSION = YES; 430 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 431 | CLANG_WARN_UNREACHABLE_CODE = YES; 432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 433 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 434 | COPY_PHASE_STRIP = YES; 435 | ENABLE_NS_ASSERTIONS = NO; 436 | ENABLE_STRICT_OBJC_MSGSEND = YES; 437 | GCC_C_LANGUAGE_STANDARD = gnu99; 438 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 439 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 440 | GCC_WARN_UNDECLARED_SELECTOR = YES; 441 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 442 | GCC_WARN_UNUSED_FUNCTION = YES; 443 | GCC_WARN_UNUSED_VARIABLE = YES; 444 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 445 | MTL_ENABLE_DEBUG_INFO = NO; 446 | SDKROOT = iphoneos; 447 | VALIDATE_PRODUCT = YES; 448 | }; 449 | name = Release; 450 | }; 451 | 0ED64E16198DE3C4001D7680 /* Debug */ = { 452 | isa = XCBuildConfiguration; 453 | baseConfigurationReference = CF75C3A00E514AF99D611AE9 /* Pods.xcconfig */; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 457 | CLANG_ENABLE_MODULES = YES; 458 | INFOPLIST_FILE = InternBookmark/Info.plist; 459 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | SWIFT_OBJC_BRIDGING_HEADER = "InternBookmark/Classes/InternBookmark-Bridging-Header.h"; 463 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 464 | }; 465 | name = Debug; 466 | }; 467 | 0ED64E17198DE3C4001D7680 /* Release */ = { 468 | isa = XCBuildConfiguration; 469 | baseConfigurationReference = CF75C3A00E514AF99D611AE9 /* Pods.xcconfig */; 470 | buildSettings = { 471 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 472 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 473 | CLANG_ENABLE_MODULES = YES; 474 | INFOPLIST_FILE = InternBookmark/Info.plist; 475 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | SWIFT_OBJC_BRIDGING_HEADER = "InternBookmark/Classes/InternBookmark-Bridging-Header.h"; 479 | }; 480 | name = Release; 481 | }; 482 | 0ED64E19198DE3C4001D7680 /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/InternBookmark.app/InternBookmark"; 486 | FRAMEWORK_SEARCH_PATHS = ( 487 | "$(SDKROOT)/Developer/Library/Frameworks", 488 | "$(inherited)", 489 | ); 490 | GCC_PREPROCESSOR_DEFINITIONS = ( 491 | "DEBUG=1", 492 | "$(inherited)", 493 | ); 494 | INFOPLIST_FILE = InternBookmarkTests/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 496 | PRODUCT_NAME = "$(TARGET_NAME)"; 497 | TEST_HOST = "$(BUNDLE_LOADER)"; 498 | }; 499 | name = Debug; 500 | }; 501 | 0ED64E1A198DE3C4001D7680 /* Release */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/InternBookmark.app/InternBookmark"; 505 | FRAMEWORK_SEARCH_PATHS = ( 506 | "$(SDKROOT)/Developer/Library/Frameworks", 507 | "$(inherited)", 508 | ); 509 | INFOPLIST_FILE = InternBookmarkTests/Info.plist; 510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | TEST_HOST = "$(BUNDLE_LOADER)"; 513 | }; 514 | name = Release; 515 | }; 516 | /* End XCBuildConfiguration section */ 517 | 518 | /* Begin XCConfigurationList section */ 519 | 0ED64DF4198DE3C4001D7680 /* Build configuration list for PBXProject "InternBookmark" */ = { 520 | isa = XCConfigurationList; 521 | buildConfigurations = ( 522 | 0ED64E13198DE3C4001D7680 /* Debug */, 523 | 0ED64E14198DE3C4001D7680 /* Release */, 524 | ); 525 | defaultConfigurationIsVisible = 0; 526 | defaultConfigurationName = Release; 527 | }; 528 | 0ED64E15198DE3C4001D7680 /* Build configuration list for PBXNativeTarget "InternBookmark" */ = { 529 | isa = XCConfigurationList; 530 | buildConfigurations = ( 531 | 0ED64E16198DE3C4001D7680 /* Debug */, 532 | 0ED64E17198DE3C4001D7680 /* Release */, 533 | ); 534 | defaultConfigurationIsVisible = 0; 535 | defaultConfigurationName = Release; 536 | }; 537 | 0ED64E18198DE3C4001D7680 /* Build configuration list for PBXNativeTarget "InternBookmarkTests" */ = { 538 | isa = XCConfigurationList; 539 | buildConfigurations = ( 540 | 0ED64E19198DE3C4001D7680 /* Debug */, 541 | 0ED64E1A198DE3C4001D7680 /* Release */, 542 | ); 543 | defaultConfigurationIsVisible = 0; 544 | defaultConfigurationName = Release; 545 | }; 546 | /* End XCConfigurationList section */ 547 | }; 548 | rootObject = 0ED64DF1198DE3C4001D7680 /* Project object */; 549 | } 550 | -------------------------------------------------------------------------------- /InternBookmark.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /InternBookmark.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /InternBookmark/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate, APIClientProtocol { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | 19 | AFNetworkActivityIndicatorManager.sharedManager().enabled = true 20 | InternBookmarkAPIClient.sharedClient().delegate = self 21 | 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(application: UIApplication!) { 26 | // 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. 27 | // 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. 28 | } 29 | 30 | func applicationDidEnterBackground(application: UIApplication!) { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(application: UIApplication!) { 36 | // 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. 37 | } 38 | 39 | func applicationDidBecomeActive(application: UIApplication!) { 40 | // 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. 41 | } 42 | 43 | func applicationWillTerminate(application: UIApplication!) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | // MARK: - IBKMInternBookmarkAPIClientDelegate 48 | 49 | func APIClientNeedsLogin(client : InternBookmarkAPIClient) { 50 | let rootViewController = UIApplication.sharedApplication().keyWindow?.rootViewController 51 | let loginViewController = rootViewController?.storyboard?.instantiateViewControllerWithIdentifier("LoginScene") as UIViewController 52 | rootViewController?.presentViewController(loginViewController, animated: true, completion: nil) 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /InternBookmark/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 89 | 95 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Controllers/BookmarkViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookmarkViewController.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/04. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookmarkViewController: UIViewController { 12 | 13 | @IBOutlet weak var titleLabel: UILabel! 14 | @IBOutlet weak var URLLabel: UILabel! 15 | @IBOutlet weak var commentLabel: UILabel! 16 | 17 | var bookmark : Bookmark? 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | title = bookmark?.entry?.title 23 | titleLabel.text = bookmark?.entry?.title 24 | URLLabel.text = bookmark?.entry?.URL?.absoluteString 25 | commentLabel.text = bookmark?.comment 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Controllers/BookmarksViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookmarksViewController.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookmarksViewController: UITableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | refreshControl = UIRefreshControl() 17 | refreshControl?.addTarget(self, action: "refreshBookmarks:", forControlEvents: .ValueChanged) 18 | 19 | refreshBookmarks(self) 20 | } 21 | 22 | func refreshBookmarks(sender: AnyObject) { 23 | refreshControl?.beginRefreshing() 24 | 25 | BookmarkManager.sharedManager().reloadBookmarksWithCompletion() { [weak self] error in 26 | if error != nil { 27 | println("error = \(error)") 28 | } 29 | self?.tableView.reloadData() 30 | self?.refreshControl?.endRefreshing() 31 | } 32 | } 33 | 34 | // MARK: - Table view data source 35 | 36 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 37 | return BookmarkManager.sharedManager().bookmarks.count 38 | } 39 | 40 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 41 | let cell = tableView.dequeueReusableCellWithIdentifier("BookmarkCell", forIndexPath: indexPath) as UITableViewCell 42 | 43 | let bookmark = BookmarkManager.sharedManager().bookmarks[indexPath.row] 44 | 45 | cell.textLabel?.text = bookmark.entry?.title 46 | cell.detailTextLabel?.text = bookmark.entry?.URL?.absoluteString 47 | 48 | return cell 49 | } 50 | 51 | // MARK: - Navigation 52 | 53 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 54 | if segue.identifier == "OpenBookmarkSegue" { 55 | if let selected = tableView?.indexPathForSelectedRow() { 56 | let bookmark = BookmarkManager.sharedManager().bookmarks[selected.row] 57 | 58 | let bookmarkViewController = segue.destinationViewController as BookmarkViewController 59 | bookmarkViewController.bookmark = bookmark 60 | } 61 | } 62 | } 63 | 64 | // MARK: - IBAction 65 | 66 | @IBAction func closeLoginSegue(segue: UIStoryboardSegue) { 67 | refreshBookmarks(self) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Controllers/LoginViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoginViewController.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/04. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class LoginViewController: UIViewController { 12 | 13 | @IBOutlet weak var webView: UIWebView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | let request: NSURLRequest = NSURLRequest(URL: InternBookmarkAPIClient.loginURL()!) 19 | webView.loadRequest(request) 20 | } 21 | 22 | func webViewDidStartLoad(webView: UIWebView!) { 23 | AFNetworkActivityIndicatorManager.sharedManager().incrementActivityCount() 24 | } 25 | 26 | func webViewDidFinishLoad(webView: UIWebView!) { 27 | AFNetworkActivityIndicatorManager.sharedManager().decrementActivityCount() 28 | } 29 | 30 | func webView(webView: UIWebView!, didFailLoadWithError error: NSError!) { 31 | AFNetworkActivityIndicatorManager.sharedManager().decrementActivityCount() 32 | if error.code != NSURLErrorCancelled { 33 | let alertController = UIAlertController(error: error) 34 | alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) 35 | presentViewController(alertController, animated: true, completion: nil) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /InternBookmark/Classes/InternBookmark-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "AFNetworking/AFNetworking.h" 6 | #import "AFNetworkActivityIndicatorManager.h" -------------------------------------------------------------------------------- /InternBookmark/Classes/Models/BookmarkManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookManager.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookmarkManager: NSObject { 12 | 13 | var bookmarks: [Bookmark] = [] 14 | 15 | class func sharedManager() -> BookmarkManager { 16 | 17 | struct Static { 18 | static let instance = BookmarkManager() 19 | } 20 | return Static.instance 21 | } 22 | 23 | func reloadBookmarksWithCompletion(completionHandler: (NSError? -> ())?) { 24 | InternBookmarkAPIClient.sharedClient().getBookmarksWithCompletion() { [weak self] results, error in 25 | if let jsonResults = results as? [String: AnyObject] { 26 | if let bookmarksJSON = jsonResults["bookmarks"] as? [AnyObject] { 27 | if let weakSelf = self { 28 | weakSelf.bookmarks = weakSelf.parseBookmarks(bookmarksJSON) 29 | } 30 | } 31 | } 32 | completionHandler?(error) 33 | } 34 | } 35 | 36 | func parseBookmarks(bookmarksJSON: [AnyObject]) -> [Bookmark] { 37 | var bookmarks: [Bookmark] = [] 38 | 39 | for bookmarkJSON in bookmarksJSON { 40 | if let bookmark = bookmarkJSON as? [String: AnyObject] { 41 | bookmarks.append(Bookmark(JSONDictionary: bookmark)) 42 | } 43 | } 44 | 45 | return bookmarks 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Models/DataModels/Bookmark.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bookmark.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct Bookmark: Printable { 12 | 13 | let bookmarkID: NSNumber? 14 | let comment: String? 15 | let entry: Entry? 16 | let user: User? 17 | let created: NSDate? 18 | let updated: NSDate? 19 | 20 | var description: String { 21 | return "" 26 | } 27 | 28 | init(JSONDictionary json: [String: AnyObject]) { 29 | if let bookmarkID = json["bookmark_id"] as? NSNumber { 30 | self.bookmarkID = bookmarkID 31 | } 32 | if let comment = json["comment"] as? String { 33 | self.comment = comment 34 | } 35 | 36 | let dateFormatter = NSDateFormatter.MySQLDateFormatter() 37 | 38 | if let created = json["created"] as? String { 39 | self.created = dateFormatter.dateFromString(created) 40 | } 41 | if let updated = json["updated"] as? String { 42 | self.updated = dateFormatter.dateFromString(updated) 43 | } 44 | if let entry = json["entry"] as? [String: AnyObject] { 45 | self.entry = Entry(JSONDictionary: entry) 46 | } 47 | if let user = json["user"] as? [String: AnyObject] { 48 | self.user = User(JSONDictionary: user) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Models/DataModels/Entry.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Entry.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct Entry: Printable { 12 | 13 | let entryID: NSNumber? 14 | let URL: NSURL? 15 | let title: String? 16 | let created: NSDate? 17 | let updated: NSDate? 18 | 19 | var description: String { 20 | return "" 24 | } 25 | 26 | init(JSONDictionary json: [String: AnyObject]) { 27 | if let entryID = json["entry_id"] as? NSNumber { 28 | self.entryID = entryID 29 | } 30 | if let URL = json["url"] as? String { 31 | self.URL = NSURL(string: URL) 32 | } 33 | if let title = json["title"] as? String { 34 | self.title = title 35 | } 36 | 37 | let dateFormatter: NSDateFormatter = NSDateFormatter.MySQLDateFormatter(); 38 | 39 | if let created = json["created"] as? String { 40 | self.created = dateFormatter.dateFromString(created) 41 | } 42 | if let updated = json["updated"] as? String { 43 | self.updated = dateFormatter.dateFromString(updated) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Models/DataModels/User.swift: -------------------------------------------------------------------------------- 1 | // 2 | // User.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct User: Printable { 12 | let userID: NSNumber? 13 | let name: String? 14 | let created: NSDate? 15 | 16 | var description: String { 17 | return "" 20 | } 21 | 22 | init(JSONDictionary json: [String: AnyObject]) { 23 | if let userID = json["user_id"] as? NSNumber { 24 | self.userID = userID 25 | } 26 | if let name = json["name"] as? String { 27 | self.name = name 28 | } 29 | 30 | let dateFormatter: NSDateFormatter = NSDateFormatter.MySQLDateFormatter() 31 | if let created = json["created"] as? String { 32 | self.created = dateFormatter.dateFromString(created) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Models/InternBookmarkAPIClient.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InternBookmarkAPIClient.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol APIClientProtocol { 12 | func APIClientNeedsLogin(client : InternBookmarkAPIClient) 13 | } 14 | 15 | struct APIClientConstants { 16 | static let APIBaseURLString: String = "http://localhost:3000" 17 | } 18 | 19 | class InternBookmarkAPIClient: NSObject { 20 | 21 | let sessionManager: AFHTTPSessionManager 22 | var delegate: APIClientProtocol? 23 | 24 | class func sharedClient() -> InternBookmarkAPIClient { 25 | struct Static { 26 | static let instance = InternBookmarkAPIClient() 27 | } 28 | return Static.instance 29 | } 30 | 31 | class func loginURL() -> NSURL? { 32 | return NSURL(string: APIClientConstants.APIBaseURLString)?.URLByAppendingPathComponent("login") 33 | } 34 | 35 | override init() { 36 | let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() 37 | configuration.HTTPAdditionalHeaders = [ 38 | "Accept" : "application/json", 39 | ] 40 | 41 | sessionManager = AFHTTPSessionManager(baseURL: NSURL(string: APIClientConstants.APIBaseURLString), 42 | sessionConfiguration: configuration) 43 | } 44 | 45 | func getBookmarksWithCompletion(completionHandler: ((AnyObject?, NSError?) -> ())?) { 46 | 47 | sessionManager.GET("/api/bookmarks", 48 | parameters: nil, 49 | success: { (_, responseObject) in 50 | completionHandler?(responseObject, nil) 51 | return 52 | }) 53 | { (task, error) in 54 | // 401 が返ったときログインが必要. 55 | if (task.response as? NSHTTPURLResponse)?.statusCode == 401 && self.needsLogin() { 56 | completionHandler?(nil, nil); 57 | } 58 | else { 59 | completionHandler?(nil, error); 60 | } 61 | } 62 | } 63 | 64 | func needsLogin() -> Bool { 65 | return (delegate?.APIClientNeedsLogin(self) != nil) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /InternBookmark/Classes/Utilities/NSDateFormatter+MySQL.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateFormatter+MySQL.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | extension NSDateFormatter { 10 | class func MySQLDateFormatter() -> NSDateFormatter { 11 | let formatter = NSDateFormatter() 12 | formatter.timeZone = NSTimeZone(abbreviation: "GMT") 13 | formatter.locale = NSLocale(localeIdentifier:"en_US") 14 | formatter.calendar = NSCalendar(calendarIdentifier: NSGregorianCalendar) 15 | formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" 16 | return formatter 17 | } 18 | } -------------------------------------------------------------------------------- /InternBookmark/Classes/Utilities/UIAlertController+NSError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+NSError.swift 3 | // InternBookmark 4 | // 5 | // Created by sakahara on 2014/08/05. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | extension UIAlertController { 10 | convenience init(error : NSError) { 11 | 12 | let message = "\n".join([error.localizedFailureReason ?? "", error.localizedRecoverySuggestion ?? ""]) 13 | self.init(title: error.localizedDescription, message: message, preferredStyle: .Alert) 14 | 15 | if let optionTitles = error.localizedRecoveryOptions as? [String] { 16 | for title in optionTitles { 17 | let action = UIAlertAction(title: title, style: .Default, handler: nil) 18 | self.addAction(action) 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /InternBookmark/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 | } -------------------------------------------------------------------------------- /InternBookmark/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 | } -------------------------------------------------------------------------------- /InternBookmark/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | jp.ne.hatena.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /InternBookmarkTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | jp.ne.hatena.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /InternBookmarkTests/InternBookmarkTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InternBookmarkTests.swift 3 | // InternBookmarkTests 4 | // 5 | // Created by sakahara on 2014/08/03. 6 | // Copyright (c) 2014年 Hatena Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class InternBookmarkTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | 3 | pod 'AFNetworking', '~> 2.0' 4 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.3.1): 3 | - AFNetworking/NSURLConnection 4 | - AFNetworking/NSURLSession 5 | - AFNetworking/Reachability 6 | - AFNetworking/Security 7 | - AFNetworking/Serialization 8 | - AFNetworking/UIKit 9 | - AFNetworking/NSURLConnection (2.3.1): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.3.1): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.3.1) 18 | - AFNetworking/Security (2.3.1) 19 | - AFNetworking/Serialization (2.3.1) 20 | - AFNetworking/UIKit (2.3.1): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | 24 | DEPENDENCIES: 25 | - AFNetworking (~> 2.0) 26 | 27 | SPEC CHECKSUMS: 28 | AFNetworking: 6d7b76aa5d04c8c37daad3eef4b7e3f2a7620da3 29 | 30 | COCOAPODS: 0.33.1 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # セットアップ 2 | 3 | ## サーバー 4 | 5 | https://github.com/hatena/Intern-Bookmark-2014 6 | 7 | `http://localhost:3000/` で動いている前提 8 | 9 | ## CocoaPods 10 | 11 | 外部モジュール管理ツールです 12 | 13 | ### CocoaPods のインストール 14 | 15 | ``` 16 | $ [sudo] gem install cocoapods 17 | $ pod setup 18 | ``` 19 | 20 | ### 外部モジュールセットアップ 21 | 22 | ``` 23 | $ pod install 24 | ``` 25 | 26 | # アプリ起動 27 | 28 | Xcode で **Run** 29 | --------------------------------------------------------------------------------