Permalink
Browse files

Finish all CouchDB requests before quitting or backgrounding.

Also tweaked the layout of the sync config screen.
  • Loading branch information...
1 parent 7eefc3a commit 0dc20af395de2712ffcf97d5cad4b6c085161fd9 @snej snej committed Aug 11, 2011
Showing with 57 additions and 141 deletions.
  1. +47 −137 Source/ConfigViewController.xib
  2. +1 −1 Source/DemoAppDelegate.h
  3. +9 −3 Source/DemoAppDelegate.m
@@ -45,7 +45,7 @@
<object class="IBUITextField" id="541780245">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{20, 172}, {280, 31}}</string>
+ <string key="NSFrame">{{20, 177}, {280, 31}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="375228555"/>
@@ -84,7 +84,7 @@
<object class="IBUILabel" id="298351939">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{20, 143}, {280, 21}}</string>
+ <string key="NSFrame">{{20, 148}, {280, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="541780245"/>
@@ -102,11 +102,11 @@
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
- <object class="IBUIFontDescription" key="IBUIFontDescription" id="1039697898">
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">2</int>
<double key="pointSize">14</double>
</object>
- <object class="NSFont" key="IBUIFont" id="540961405">
+ <object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica-Bold</string>
<double key="NSSize">14</double>
<int key="NSfFlags">16</int>
@@ -115,7 +115,7 @@
<object class="IBUILabel" id="249887243">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{20, 68}, {280, 62}}</string>
+ <string key="NSFrame">{{20, 64}, {280, 77}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="298351939"/>
@@ -125,13 +125,13 @@
<int key="IBUIContentMode">7</int>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <string key="IBUIText">Grocery Sync is powered by Couchbase Mobile. Your shopping list can be synchronized with any available Couchbase Server or Apache CouchDB.</string>
+ <string key="IBUIText">Grocery Sync is powered by Couchbase Mobile. Your shopping list can be synchronized with any available Couchbase Server or Apache CouchDB. Multiple devices can be synchronized with the same server database, keeping them in constant sync.</string>
<reference key="IBUITextColor" ref="1064221978"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<float key="IBUIMinimumFontSize">10</float>
- <int key="IBUINumberOfLines">3</int>
+ <int key="IBUINumberOfLines">5</int>
<int key="IBUILineBreakMode">0</int>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
@@ -143,119 +143,50 @@
<int key="NSfFlags">16</int>
</object>
</object>
- <object class="IBUIButton" id="881876439">
+ <object class="IBUIButton" id="724717968">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">269</int>
- <string key="NSFrame">{{86, 275}, {149, 35}}</string>
+ <string key="NSFrame">{{67, 261}, {187, 35}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="68799902"/>
+ <reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:196</string>
<bool key="IBUIOpaque">NO</bool>
+ <int key="IBUITag">2</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
- <string key="IBUINormalTitle">Couchbase Server</string>
- <object class="NSColor" key="IBUIHighlightedTitleColor" id="125638281">
+ <string key="IBUINormalTitle">How To Get A Database</string>
+ <object class="NSColor" key="IBUIHighlightedTitleColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
- <object class="NSColor" key="IBUINormalTitleShadowColor" id="1041132842">
+ <object class="NSColor" key="IBUINormalTitleShadowColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
- <object class="IBUIFontDescription" key="IBUIFontDescription" id="620671735">
+ <object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
<double key="pointSize">15</double>
</object>
- <object class="NSFont" key="IBUIFont" id="845009120">
+ <object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
</object>
- <object class="IBUIButton" id="68799902">
- <reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">269</int>
- <string key="NSFrame">{{86, 318}, {149, 35}}</string>
- <reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="724717968"/>
- <string key="NSReuseIdentifierKey">_NS:196</string>
- <bool key="IBUIOpaque">NO</bool>
- <int key="IBUITag">1</int>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <int key="IBUIContentHorizontalAlignment">0</int>
- <int key="IBUIContentVerticalAlignment">0</int>
- <int key="IBUIButtonType">1</int>
- <string key="IBUINormalTitle">Apache CouchDB</string>
- <reference key="IBUIHighlightedTitleColor" ref="125638281"/>
- <object class="NSColor" key="IBUINormalTitleColor">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
- </object>
- <reference key="IBUINormalTitleShadowColor" ref="1041132842"/>
- <reference key="IBUIFontDescription" ref="620671735"/>
- <reference key="IBUIFont" ref="845009120"/>
- </object>
- <object class="IBUIButton" id="724717968">
- <reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">269</int>
- <string key="NSFrame">{{86, 361}, {149, 35}}</string>
- <reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
- <string key="NSReuseIdentifierKey">_NS:196</string>
- <bool key="IBUIOpaque">NO</bool>
- <int key="IBUITag">2</int>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <int key="IBUIContentHorizontalAlignment">0</int>
- <int key="IBUIContentVerticalAlignment">0</int>
- <int key="IBUIButtonType">1</int>
- <string key="IBUINormalTitle">Iris Couch Hosting</string>
- <reference key="IBUIHighlightedTitleColor" ref="125638281"/>
- <object class="NSColor" key="IBUINormalTitleColor">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
- </object>
- <reference key="IBUINormalTitleShadowColor" ref="1041132842"/>
- <reference key="IBUIFontDescription" ref="620671735"/>
- <reference key="IBUIFont" ref="845009120"/>
- </object>
- <object class="IBUILabel" id="359335565">
- <reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">266</int>
- <string key="NSFrame">{{20, 246}, {280, 21}}</string>
- <reference key="NSSuperview" ref="191373211"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="881876439"/>
- <string key="NSReuseIdentifierKey">_NS:129</string>
- <bool key="IBUIOpaque">NO</bool>
- <bool key="IBUIClipsSubviews">YES</bool>
- <int key="IBUIContentMode">7</int>
- <bool key="IBUIUserInteractionEnabled">NO</bool>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <string key="IBUIText">Click to learn more about:</string>
- <reference key="IBUITextColor" ref="1064221978"/>
- <nil key="IBUIHighlightedColor"/>
- <int key="IBUIBaselineAdjustment">1</int>
- <float key="IBUIMinimumFontSize">10</float>
- <int key="IBUITextAlignment">1</int>
- <reference key="IBUIFontDescription" ref="1039697898"/>
- <reference key="IBUIFont" ref="540961405"/>
- </object>
<object class="IBUILabel" id="375228555">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{20, 205}, {280, 21}}</string>
+ <string key="NSFrame">{{20, 210}, {280, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="359335565"/>
+ <reference key="NSNextKeyView" ref="724717968"/>
<string key="NSReuseIdentifierKey">_NS:129</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -284,7 +215,7 @@
<object class="IBUIImageView" id="206850384">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">290</int>
- <string key="NSFrame">{{20, 7}, {280, 73}}</string>
+ <string key="NSFrame">{{20, -4}, {280, 73}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="249887243"/>
@@ -336,24 +267,6 @@
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">learnMore:</string>
- <reference key="source" ref="881876439"/>
- <reference key="destination" ref="372490531"/>
- <int key="IBEventType">7</int>
- </object>
- <int key="connectionID">19</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchEventConnection" key="connection">
- <string key="label">learnMore:</string>
- <reference key="source" ref="68799902"/>
- <reference key="destination" ref="372490531"/>
- <int key="IBEventType">7</int>
- </object>
- <int key="connectionID">20</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchEventConnection" key="connection">
- <string key="label">learnMore:</string>
<reference key="source" ref="724717968"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
@@ -377,15 +290,12 @@
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="881876439"/>
- <reference ref="68799902"/>
- <reference ref="724717968"/>
- <reference ref="359335565"/>
<reference ref="541780245"/>
<reference ref="298351939"/>
<reference ref="375228555"/>
<reference ref="249887243"/>
<reference ref="206850384"/>
+ <reference ref="724717968"/>
</object>
<reference key="parent" ref="0"/>
</object>
@@ -416,26 +326,11 @@
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">12</int>
- <reference key="object" ref="881876439"/>
- <reference key="parent" ref="191373211"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">13</int>
- <reference key="object" ref="68799902"/>
- <reference key="parent" ref="191373211"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="724717968"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">15</int>
- <reference key="object" ref="359335565"/>
- <reference key="parent" ref="191373211"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">18</int>
<reference key="object" ref="375228555"/>
<reference key="parent" ref="191373211"/>
@@ -457,10 +352,7 @@
<string>-2.IBPluginDependency</string>
<string>1.IBPluginDependency</string>
<string>11.IBPluginDependency</string>
- <string>12.IBPluginDependency</string>
- <string>13.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
- <string>15.IBPluginDependency</string>
<string>18.IBPluginDependency</string>
<string>22.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
@@ -479,9 +371,6 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -505,14 +394,35 @@
<string key="className">ConfigViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
- <string key="NS.key.0">learnMore:</string>
- <string key="NS.object.0">id</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>done:</string>
+ <string>learnMore:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ </object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
- <string key="NS.key.0">learnMore:</string>
- <object class="IBActionInfo" key="NS.object.0">
- <string key="name">learnMore:</string>
- <string key="candidateClassName">id</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>done:</string>
+ <string>learnMore:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">done:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">learnMore:</string>
+ <string key="candidateClassName">id</string>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -25,11 +25,11 @@
@interface DemoAppDelegate : NSObject <UIApplicationDelegate, UIAlertViewDelegate,
CouchbaseDelegate> {
-
UIWindow *window;
UINavigationController *navigationController;
UIImageView *splashView;
+
CouchDatabase *database;
}
@@ -111,6 +111,7 @@ -(void)couchbaseDidStart:(NSURL *)serverURL {
CouchServer *server = [[CouchServer alloc] initWithURL: serverURL];
self.database = [server databaseNamed: kDatabaseName];
[server release];
+ self.database.tracksActiveOperations = YES;
#if !INSTALL_CANNED_DATABASE
// Create the database on the first run of the app.
@@ -128,10 +129,15 @@ -(void)couchbaseDidStart:(NSURL *)serverURL {
- (void)applicationDidEnterBackground:(UIApplication *)application {
- // CouchDB seems to get stuck when in background. exit() so we get relaunched freshly.
- // (Setting the UIApplicationExitsOnSuspend key in the Info.plist accomplishes the same goal.)
+ // Make sure all transactions complete, because going into the background will
+ // close down the CouchDB server:
+ [RESTOperation wait: self.database.activeOperations];
+}
+
- exit(0);
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Make sure all transactions complete before quitting:
+ [RESTOperation wait: self.database.activeOperations];
}

0 comments on commit 0dc20af

Please sign in to comment.