Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial import

  • Loading branch information...
commit 620f56d0647be279e158dbcdcc4b098f6d57b020 0 parents
vickeryj authored
Showing with 7,111 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +30 −0 Info.plist
  3. +329 −0 MainWindow.xib
  4. +20 −0 NotesExampleApp/Note.h
  5. +23 −0 NotesExampleApp/Note.m
  6. +206 −0 NotesExampleApp/NoteEdit.xib
  7. +21 −0 NotesExampleApp/NoteEditController.h
  8. +38 −0 NotesExampleApp/NoteEditController.m
  9. +22 −0 NotesExampleApp/NoteListController.h
  10. +60 −0 NotesExampleApp/NoteListController.m
  11. +17 −0 NotesExampleApp/main.m
  12. +22 −0 NotesExampleApp/objectivesyncAppDelegate.h
  13. +34 −0 NotesExampleApp/objectivesyncAppDelegate.m
  14. +43 −0 external_libs/ObjectiveRecord/NSData-SQLitePersistence.h
  15. +47 −0 external_libs/ObjectiveRecord/NSData-SQLitePersistence.m
  16. +46 −0 external_libs/ObjectiveRecord/NSDate-SQLitePersistence.h
  17. +53 −0 external_libs/ObjectiveRecord/NSDate-SQLitePersistence.m
  18. +29 −0 external_libs/ObjectiveRecord/NSMutableData-SQLitePersistence.h
  19. +30 −0 external_libs/ObjectiveRecord/NSMutableData-SQLitePersistence.m
  20. +47 −0 external_libs/ObjectiveRecord/NSNumber-SQLitePersistence.h
  21. +52 −0 external_libs/ObjectiveRecord/NSNumber-SQLitePersistence.m
  22. +94 −0 external_libs/ObjectiveRecord/NSObject-SQLitePersistence.h
  23. +66 −0 external_libs/ObjectiveRecord/NSObject-SQLitePersistence.m
  24. +27 −0 external_libs/ObjectiveRecord/NSString-SQLiteColumnName.h
  25. +61 −0 external_libs/ObjectiveRecord/NSString-SQLiteColumnName.m
  26. +46 −0 external_libs/ObjectiveRecord/NSString-SQLitePersistence.h
  27. +44 −0 external_libs/ObjectiveRecord/NSString-SQLitePersistence.m
  28. +27 −0 external_libs/ObjectiveRecord/NSString-UppercaseFirst.h
  29. +37 −0 external_libs/ObjectiveRecord/NSString-UppercaseFirst.m
  30. +15 −0 external_libs/ObjectiveRecord/ORCDataChangedDelegate.h
  31. +40 −0 external_libs/ObjectiveRecord/SQLiteInstanceManager.h
  32. +280 −0 external_libs/ObjectiveRecord/SQLiteInstanceManager.m
  33. +123 −0 external_libs/ObjectiveRecord/SQLitePersistentObject.h
  34. +518 −0 external_libs/ObjectiveRecord/SQLitePersistentObject.m
  35. +23 −0 external_libs/ObjectiveResource/Connection.h
  36. +137 −0 external_libs/ObjectiveResource/Connection.m
  37. +30 −0 external_libs/ObjectiveResource/ConnectionDelegate.h
  38. +84 −0 external_libs/ObjectiveResource/ConnectionDelegate.m
  39. +15 −0 external_libs/ObjectiveResource/NSHTTPURLResponse+Error.h
  40. +33 −0 external_libs/ObjectiveResource/NSHTTPURLResponse+Error.m
  41. +13 −0 external_libs/ObjectiveResource/NSMutableURLRequest+ResponseType.h
  42. +32 −0 external_libs/ObjectiveResource/NSMutableURLRequest+ResponseType.m
  43. +13 −0 external_libs/ObjectiveResource/ObjectiveResource+JSONSerializableSupport.h
  44. +17 −0 external_libs/ObjectiveResource/ObjectiveResource+JSONSerializableSupport.m
  45. +15 −0 external_libs/ObjectiveResource/ObjectiveResource+XMLSerializableSupport.h
  46. +21 −0 external_libs/ObjectiveResource/ObjectiveResource+XMLSerializableSupport.m
  47. +71 −0 external_libs/ObjectiveResource/ObjectiveResource.h
  48. +312 −0 external_libs/ObjectiveResource/ObjectiveResource.m
  49. +34 −0 external_libs/ObjectiveResource/Response.h
  50. +73 −0 external_libs/ObjectiveResource/Response.m
  51. +11 −0 external_libs/ObjectiveSupport/Core/CoreSupport.h
  52. +42 −0 external_libs/ObjectiveSupport/Core/Inflections/NSString+InflectionSupport.h
  53. +93 −0 external_libs/ObjectiveSupport/Core/Inflections/NSString+InflectionSupport.m
  54. +12 −0 external_libs/ObjectiveSupport/Core/NSData+Additions.h
  55. +161 −0 external_libs/ObjectiveSupport/Core/NSData+Additions.m
  56. +32 −0 external_libs/ObjectiveSupport/Core/NSObject+PropertySupport.h
  57. +76 −0 external_libs/ObjectiveSupport/Core/NSObject+PropertySupport.m
  58. +19 −0 external_libs/ObjectiveSupport/Core/NSString+GSub.h
  59. +25 −0 external_libs/ObjectiveSupport/Core/NSString+GSub.m
  60. +22 −0 external_libs/ObjectiveSupport/Core/ObjectiveResourceDateFormatter.h
  61. +57 −0 external_libs/ObjectiveSupport/Core/ObjectiveResourceDateFormatter.m
  62. +11 −0 external_libs/ObjectiveSupport/Core/ObjectiveSupport.h
  63. +78 −0 external_libs/ObjectiveSupport/Serialization/JSON/JSONSerializable.h
  64. +2 −0  external_libs/ObjectiveSupport/Serialization/JSON/JSONSerializableSupport.h
  65. +14 −0 external_libs/ObjectiveSupport/Serialization/JSON/NSDictionary+JSONSerializableSupport.h
  66. +30 −0 external_libs/ObjectiveSupport/Serialization/JSON/NSDictionary+JSONSerializableSupport.m
  67. +23 −0 external_libs/ObjectiveSupport/Serialization/JSON/NSObject+JSONSerializableSupport.h
  68. +113 −0 external_libs/ObjectiveSupport/Serialization/JSON/NSObject+JSONSerializableSupport.m
  69. +13 −0 external_libs/ObjectiveSupport/Serialization/NSDate+Serialize.h
  70. +23 −0 external_libs/ObjectiveSupport/Serialization/NSDate+Serialize.m
  71. +16 −0 external_libs/ObjectiveSupport/Serialization/NSDictionary+KeyTranslation.h
  72. +19 −0 external_libs/ObjectiveSupport/Serialization/NSDictionary+KeyTranslation.m
  73. +14 −0 external_libs/ObjectiveSupport/Serialization/NSObject+Serialize.h
  74. +22 −0 external_libs/ObjectiveSupport/Serialization/NSObject+Serialize.m
  75. +16 −0 external_libs/ObjectiveSupport/Serialization/NSString+Serialize.h
  76. +19 −0 external_libs/ObjectiveSupport/Serialization/NSString+Serialize.m
  77. +11 −0 external_libs/ObjectiveSupport/Serialization/Serialize.h
  78. +32 −0 external_libs/ObjectiveSupport/Serialization/XML/FromXMLElementDelegate.h
  79. +175 −0 external_libs/ObjectiveSupport/Serialization/XML/FromXMLElementDelegate.m
  80. +13 −0 external_libs/ObjectiveSupport/Serialization/XML/NSArray+XMLSerializableSupport.h
  81. +25 −0 external_libs/ObjectiveSupport/Serialization/XML/NSArray+XMLSerializableSupport.m
  82. +13 −0 external_libs/ObjectiveSupport/Serialization/XML/NSDate+XMLSerializableSupport.h
  83. +29 −0 external_libs/ObjectiveSupport/Serialization/XML/NSDate+XMLSerializableSupport.m
  84. +15 −0 external_libs/ObjectiveSupport/Serialization/XML/NSDictionary+XMLSerializableSupport.h
  85. +33 −0 external_libs/ObjectiveSupport/Serialization/XML/NSDictionary+XMLSerializableSupport.m
  86. +11 −0 external_libs/ObjectiveSupport/Serialization/XML/NSNull+XMLSerializableSupport.h
  87. +17 −0 external_libs/ObjectiveSupport/Serialization/XML/NSNull+XMLSerializableSupport.m
  88. +51 −0 external_libs/ObjectiveSupport/Serialization/XML/NSObject+XMLSerializableSupport.h
  89. +128 −0 external_libs/ObjectiveSupport/Serialization/XML/NSObject+XMLSerializableSupport.m
  90. +17 −0 external_libs/ObjectiveSupport/Serialization/XML/NSString+XMLSerializableSupport.h
  91. +30 −0 external_libs/ObjectiveSupport/Serialization/XML/NSString+XMLSerializableSupport.m
  92. +79 −0 external_libs/ObjectiveSupport/Serialization/XML/XMLSerializable.h
  93. +14 −0 external_libs/ObjectiveSupport/Serialization/XML/XMLSerializableSupport.h
  94. +11 −0 external_libs/ObjectiveSupport/json-framework/JSONFramework.h
  95. +60 −0 external_libs/ObjectiveSupport/json-framework/NSObject+SBJSON.h
  96. +57 −0 external_libs/ObjectiveSupport/json-framework/NSObject+SBJSON.m
  97. +41 −0 external_libs/ObjectiveSupport/json-framework/NSString+SBJSON.h
  98. +60 −0 external_libs/ObjectiveSupport/json-framework/NSString+SBJSON.m
  99. +137 −0 external_libs/ObjectiveSupport/json-framework/SBJSON.h
  100. +740 −0 external_libs/ObjectiveSupport/json-framework/SBJSON.m
  101. +16 −0 lib/OSYDataChangedDelegate.h
  102. +22 −0 lib/OSYDataChangedDelegate.m
  103. +26 −0 lib/OSYLog.h
  104. +34 −0 lib/OSYLog.m
  105. +22 −0 lib/OSYObjectiveResourceProxy.h
  106. +47 −0 lib/OSYObjectiveResourceProxy.m
  107. +20 −0 lib/OSYService.h
  108. +40 −0 lib/OSYService.m
  109. +636 −0 objectivesync.xcodeproj/project.pbxproj
  110. +8 −0 objectivesync_Prefix.pch
8 .gitignore
@@ -0,0 +1,8 @@
+# osx noise
+.DS_Store
+
+# xcode noise
+build/*
+*.pbxuser
+*.mode1v3
+*.mode2v3
30 Info.plist
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.${PRODUCT_NAME:identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+</dict>
+</plist>
329 MainWindow.xib
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
+ <data>
+ <int key="IBDocument.SystemTarget">528</int>
+ <string key="IBDocument.SystemVersion">9G55</string>
+ <string key="IBDocument.InterfaceBuilderVersion">677</string>
+ <string key="IBDocument.AppKitVersion">949.43</string>
+ <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="2"/>
+ <integer value="11"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="841351856">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ </object>
+ <object class="IBProxyObject" id="427554174">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ </object>
+ <object class="IBUICustomObject" id="664661524"/>
+ <object class="IBUIWindow" id="380026005">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">1316</int>
+ <object class="NSPSMatrix" key="NSFrameMatrix"/>
+ <string key="NSFrameSize">{320, 480}</string>
+ <reference key="NSSuperview"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MSAxIDEAA</bytes>
+ </object>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ </object>
+ <object class="IBUINavigationController" id="982135563">
+ <object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
+ <bool key="IBUIPrompted">NO</bool>
+ </object>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <object class="IBUINavigationBar" key="IBUINavigationBar" id="971918988">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{0, -44}, {0, 44}}</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="IBUIViewControllers">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUIViewController" id="295249404">
+ <string key="IBUITitle">Notes</string>
+ <object class="IBUINavigationItem" key="IBUINavigationItem" id="170839311">
+ <reference key="IBUINavigationBar"/>
+ <string key="IBUITitle">Notes</string>
+ <object class="IBUIBarButtonItem" key="IBUIRightBarButtonItem" id="231085399">
+ <int key="IBUIStyle">1</int>
+ <int key="IBUISystemItemIdentifier">4</int>
+ </object>
+ </object>
+ <reference key="IBUIParentViewController" ref="982135563"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="841351856"/>
+ <reference key="destination" ref="664661524"/>
+ </object>
+ <int key="connectionID">4</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">window</string>
+ <reference key="source" ref="664661524"/>
+ <reference key="destination" ref="380026005"/>
+ </object>
+ <int key="connectionID">5</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">navigationController</string>
+ <reference key="source" ref="664661524"/>
+ <reference key="destination" ref="982135563"/>
+ </object>
+ <int key="connectionID">14</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchEventConnection" key="connection">
+ <string key="label">addButtonPressed</string>
+ <reference key="source" ref="231085399"/>
+ <reference key="destination" ref="295249404"/>
+ </object>
+ <int key="connectionID">17</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="957960031">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">2</int>
+ <reference key="object" ref="380026005"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="parent" ref="957960031"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="841351856"/>
+ <reference key="parent" ref="957960031"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">3</int>
+ <reference key="object" ref="664661524"/>
+ <reference key="parent" ref="957960031"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="427554174"/>
+ <reference key="parent" ref="957960031"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">10</int>
+ <reference key="object" ref="982135563"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="295249404"/>
+ <reference ref="971918988"/>
+ </object>
+ <reference key="parent" ref="957960031"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">11</int>
+ <reference key="object" ref="295249404"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="170839311"/>
+ </object>
+ <reference key="parent" ref="982135563"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">12</int>
+ <reference key="object" ref="971918988"/>
+ <reference key="parent" ref="982135563"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">15</int>
+ <reference key="object" ref="170839311"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="231085399"/>
+ </object>
+ <reference key="parent" ref="295249404"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">16</int>
+ <reference key="object" ref="231085399"/>
+ <reference key="parent" ref="170839311"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.CustomClassName</string>
+ <string>-2.CustomClassName</string>
+ <string>10.IBEditorWindowLastContentRect</string>
+ <string>10.IBPluginDependency</string>
+ <string>11.CustomClassName</string>
+ <string>11.IBPluginDependency</string>
+ <string>12.IBPluginDependency</string>
+ <string>15.IBPluginDependency</string>
+ <string>16.IBPluginDependency</string>
+ <string>2.IBAttributePlaceholdersKey</string>
+ <string>2.IBEditorWindowLastContentRect</string>
+ <string>2.IBPluginDependency</string>
+ <string>3.CustomClassName</string>
+ <string>3.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UIApplication</string>
+ <string>UIResponder</string>
+ <string>{{59, 617}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>NoteListController</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 class="NSMutableDictionary">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <string>{{457, 51}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>objectivesyncAppDelegate</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">17</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveRecord/NSObject-SQLitePersistence.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveSupport/Core/NSObject+PropertySupport.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveSupport/json-framework/NSObject+SBJSON.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NoteListController</string>
+ <string key="superclassName">UITableViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">addButtonPressed</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">NotesExampleApp/NoteListController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">objectivesyncAppDelegate</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>navigationController</string>
+ <string>window</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UINavigationController</string>
+ <string>UIWindow</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">NotesExampleApp/objectivesyncAppDelegate.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">objectivesyncAppDelegate</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.LastKnownRelativeProjectPath">objectivesync.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ </data>
+</archive>
20 NotesExampleApp/Note.h
@@ -0,0 +1,20 @@
+//
+// Note.h
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SQLitePersistentObject.h"
+
+@interface Note : SQLitePersistentObject {
+
+ NSString *noteText;
+
+}
+
+@property(nonatomic, retain) NSString *noteText;
+
+@end
23 NotesExampleApp/Note.m
@@ -0,0 +1,23 @@
+//
+// Note.m
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import "Note.h"
+
+@implementation Note
+
+@synthesize noteText;
+
+#pragma mark cleanup
+- (void) dealloc
+{
+ [noteText release];
+ [super dealloc];
+}
+
+
+@end
206 NotesExampleApp/NoteEdit.xib
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
+ <data>
+ <int key="IBDocument.SystemTarget">528</int>
+ <string key="IBDocument.SystemVersion">9G55</string>
+ <string key="IBDocument.InterfaceBuilderVersion">677</string>
+ <string key="IBDocument.AppKitVersion">949.43</string>
+ <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="4"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ </object>
+ <object class="IBProxyObject" id="975951072">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ </object>
+ <object class="IBUIView" id="191373211">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">292</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUITextView" id="665224587">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrameSize">{320, 480}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
+ <bool key="IBUIDelaysContentTouches">NO</bool>
+ <bool key="IBUICanCancelContentTouches">NO</bool>
+ <bool key="IBUIBouncesZoom">NO</bool>
+ <string key="IBUIText">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
+ </object>
+ </object>
+ <string key="NSFrameSize">{320, 480}</string>
+ <reference key="NSSuperview"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="191373211"/>
+ </object>
+ <int key="connectionID">5</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">textView</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="665224587"/>
+ </object>
+ <int key="connectionID">6</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="360949347">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1</int>
+ <reference key="object" ref="191373211"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="665224587"/>
+ </object>
+ <reference key="parent" ref="360949347"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="360949347"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="975951072"/>
+ <reference key="parent" ref="360949347"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">4</int>
+ <reference key="object" ref="665224587"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.CustomClassName</string>
+ <string>-2.CustomClassName</string>
+ <string>1.IBEditorWindowLastContentRect</string>
+ <string>1.IBPluginDependency</string>
+ <string>4.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NoteEditController</string>
+ <string>UIResponder</string>
+ <string>{{354, 412}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">6</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveRecord/NSObject-SQLitePersistence.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveSupport/Core/NSObject+PropertySupport.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">external_libs/ObjectiveSupport/json-framework/NSObject+SBJSON.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NoteEditController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">textView</string>
+ <string key="NS.object.0">UITextView</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">NotesExampleApp/NoteEditController.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../objectivesync.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ </data>
+</archive>
21 NotesExampleApp/NoteEditController.h
@@ -0,0 +1,21 @@
+//
+// NoteEditController.h
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class Note;
+
+@interface NoteEditController : UIViewController {
+
+ IBOutlet UITextView *textView;
+ Note *note;
+}
+
+@property(nonatomic, retain) Note *note;
+
+@end
38 NotesExampleApp/NoteEditController.m
@@ -0,0 +1,38 @@
+//
+// NoteEditController.m
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import "NoteEditController.h"
+#import "Note.h"
+
+@implementation NoteEditController
+
+@synthesize note;
+
+#pragma mark UIViewController methods
+- (void)viewWillAppear:(BOOL)animated {
+ textView.text = [note noteText];
+}
+- (void)viewDidAppear:(BOOL)animated {
+ [textView becomeFirstResponder];
+}
+- (void)viewWillDisappear:(BOOL)animated {
+ note.noteText = textView.text;
+ [note save];
+}
+
+
+
+#pragma mark cleanup
+
+- (void)dealloc {
+ [note release];
+ [super dealloc];
+}
+
+
+@end
22 NotesExampleApp/NoteListController.h
@@ -0,0 +1,22 @@
+//
+// NoteListController.h
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface NoteListController : UITableViewController {
+
+ NSMutableArray *notes;
+
+}
+
+- (IBAction) addButtonPressed;
+
+@property(nonatomic, retain) NSMutableArray *notes;
+
+@end
60 NotesExampleApp/NoteListController.m
@@ -0,0 +1,60 @@
+//
+// NoteListController.m
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+#import "NoteListController.h"
+#import "Note.h"
+#import "NoteEditController.h"
+
+@implementation NoteListController
+
+@synthesize notes;
+
+
+- (IBAction) addButtonPressed {
+ NoteEditController *editor = [[[NoteEditController alloc] initWithNibName:@"NoteEdit" bundle:nil] autorelease];
+ editor.note = [[[Note alloc] init] autorelease];
+ [notes addObject:editor.note];
+ [self.navigationController pushViewController:editor animated:YES];
+}
+
+#pragma mark UIViewController methods
+- (void)viewDidLoad {
+ self.notes = [NSMutableArray arrayWithArray:[Note findByCriteria:@""]];
+}
+
+- (void)viewDidAppear:(BOOL)animated {
+ [self.tableView reloadData];
+}
+
+
+#pragma mark Table view methods
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ return [notes count];
+}
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
+ }
+ cell.text = [[notes objectAtIndex:indexPath.row] noteText];
+ return cell;
+}
+
+#pragma mark cleanup
+- (void)dealloc {
+ [notes release];
+ [super dealloc];
+}
+
+
+@end
+
17 NotesExampleApp/main.m
@@ -0,0 +1,17 @@
+//
+// main.m
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright Joshua Vickery 2009. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+int main(int argc, char *argv[]) {
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ [pool release];
+ return retVal;
+}
22 NotesExampleApp/objectivesyncAppDelegate.h
@@ -0,0 +1,22 @@
+//
+// objectivesyncAppDelegate.h
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright Joshua Vickery 2009. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface objectivesyncAppDelegate : NSObject <UIApplicationDelegate> {
+ UIWindow *window;
+ UINavigationController *navigationController;
+}
+
+@property (nonatomic, retain) IBOutlet UIWindow *window;
+@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
+
+
+@end
+
34 NotesExampleApp/objectivesyncAppDelegate.m
@@ -0,0 +1,34 @@
+//
+// objectivesyncAppDelegate.m
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright Joshua Vickery 2009. All rights reserved.
+//
+
+#import "objectivesyncAppDelegate.h"
+#import "OSYService.h"
+
+@implementation objectivesyncAppDelegate
+
+@synthesize window, navigationController;
+
+
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+
+ [OSYService setup];
+
+ // Override point for customization after application launch
+ [window addSubview:navigationController.view];
+ [window makeKeyAndVisible];
+}
+
+
+- (void)dealloc {
+ [window release];
+ [navigationController release];
+ [super dealloc];
+}
+
+
+@end
43 external_libs/ObjectiveRecord/NSData-SQLitePersistence.h
@@ -0,0 +1,43 @@
+//
+// NSData-SQLitePersistence.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import <Foundation/Foundation.h>
+#import "NSObject-SQLitePersistence.h"
+
+@interface NSData(SQLitePersistence) <SQLitePersistence>
+/*!
+ This method initializes an NSData from blob pulled from the database.
+ */
++ (id)objectWithSQLBlobRepresentation:(NSData *)data;
+/*!
+ This method returns self as a Base-64 encoded NSString.
+ */
+- (NSData *)sqlBlobRepresentationOfSelf;
+
+/*!
+ Returns YES to indicate it can be stored in a column of a database
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns REAL to inidicate this object can be stored in a TEXT column
+ */
++ (NSString *)columnTypeForObjectStorage;
++ (BOOL)shouldBeStoredInBlob;
+@end
47 external_libs/ObjectiveRecord/NSData-SQLitePersistence.m
@@ -0,0 +1,47 @@
+//
+// NSData-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import "NSData-SQLitePersistence.h"
+//#import "NSData-Base64.h"
+
+@implementation NSData(SQLitePersistence)
+
+- (NSData *)sqlBlobRepresentationOfSelf
+{
+ return self;
+}
++ (BOOL)canBeStoredInSQLite
+{
+ return YES;
+}
++ (NSString *)columnTypeForObjectStorage
+{
+ return kSQLiteColumnTypeText; // Look at using blob
+}
++ (BOOL)shouldBeStoredInBlob
+{
+ return YES;
+}
++ (id)objectWithSQLBlobRepresentation:(NSData *)data;
+{
+ // Simple pass through
+ return data;
+}
+@end
46 external_libs/ObjectiveRecord/NSDate-SQLitePersistence.h
@@ -0,0 +1,46 @@
+//
+// NSDate-SQLitePersistence.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+#import "NSObject-SQLitePersistence.h"
+
+@interface NSDate(SQLitePersistence) <SQLitePersistence>
+/*!
+ This method initializes an NSDate from REAL colum data pulled from the database.
+ */
++ (id)objectWithSqlColumnRepresentation:(NSString *)columnData;
+
+/*!
+ This method returns self the time interval since 1970 ncoded NSString.
+ */
+- (NSString *)sqlColumnRepresentationOfSelf;
+
+/*!
+ Returns YES to indicate it can be stored in a column of a database
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns REAL to inidicate this object can be stored in a TEXT column
+ */
++ (NSString *)columnTypeForObjectStorage;
+
++ (BOOL)shouldBeStoredInBlob;
+@end
53 external_libs/ObjectiveRecord/NSDate-SQLitePersistence.m
@@ -0,0 +1,53 @@
+//
+// NSDate-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import "NSDate-SQLitePersistence.h"
+
+
+@implementation NSDate(SQLitePersistence)
++ (id)objectWithSqlColumnRepresentation:(NSString *)columnData;
+{
+ NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSSS"];
+ return [dateFormatter dateFromString:columnData];
+}
+- (NSString *)sqlColumnRepresentationOfSelf
+{
+
+ NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
+ [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSSS"];
+
+ NSString *formattedDateString = [dateFormatter stringFromDate:self];
+ [dateFormatter release];
+
+ return formattedDateString;
+}
++ (BOOL)canBeStoredInSQLite
+{
+ return YES;
+}
++ (NSString *)columnTypeForObjectStorage
+{
+ return kSQLiteColumnTypeReal;
+}
++ (BOOL)shouldBeStoredInBlob
+{
+ return NO;
+}
+@end
29 external_libs/ObjectiveRecord/NSMutableData-SQLitePersistence.h
@@ -0,0 +1,29 @@
+//
+// NSMutableData-SQLitePersistence.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import <Foundation/Foundation.h>
+#import "NSObject-SQLitePersistence.h"
+#import "NSData-SQLitePersistence.h"
+
+@interface NSMutableData(SQLitePersistence)
+/*!
+ This method initializes an NSData from blob pulled from the database.
+ */
+- (id)initWithSQLBlobRepresentation:(NSData *)data;
+@end
30 external_libs/ObjectiveRecord/NSMutableData-SQLitePersistence.m
@@ -0,0 +1,30 @@
+//
+// NSMutableData-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import "NSMutableData-SQLitePersistence.h"
+
+
+@implementation NSMutableData(SQLitePersistence)
+- (id)initWithSQLBlobRepresentation:(NSData *)data
+{
+ self = [[NSMutableData dataWithData:data] retain];
+ return self;
+}
+@end
47 external_libs/ObjectiveRecord/NSNumber-SQLitePersistence.h
@@ -0,0 +1,47 @@
+//
+// NSNumber-SQLitePersistence.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+#import "NSObject-SQLitePersistence.h"
+
+@interface NSNumber(SQLitePersistence) <SQLitePersistence>
+
+/*!
+ This method initializes an NSNumber from REAL colum data pulled from the database.
+ */
++ (id)ObjectWithSqlColumnRepresentation:(NSString *)columnData;
+
+/*!
+ This method returns self as a number.
+ */
+- (NSString *)sqlColumnRepresentationOfSelf;
+
+/*!
+ Returns YES to indicate it can be stored in a column of a database
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns REAL to inidicate this object can be stored in a REAL column
+ */
++ (NSString *)columnTypeForObjectStorage;
+
++ (BOOL)shouldBeStoredInBlob;
+@end
52 external_libs/ObjectiveRecord/NSNumber-SQLitePersistence.m
@@ -0,0 +1,52 @@
+//
+// NSNumber-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import "NSNumber-SQLitePersistence.h"
+
+
+@implementation NSNumber(SQLitePersistence)
++ (id)ObjectWithSqlColumnRepresentation:(NSString *)columnData
+{
+ double doubleValue = [columnData doubleValue];
+ long long longValue = [columnData longLongValue];
+
+ if (doubleValue == longValue)
+ self = [[NSNumber alloc] initWithLongLong:longValue];
+ else
+ self = [[NSNumber alloc] initWithDouble:doubleValue];
+
+ return self;
+}
+- (NSString *)sqlColumnRepresentationOfSelf
+{
+ return [self stringValue];
+}
++ (BOOL)canBeStoredInSQLite
+{
+ return YES;
+}
++ (NSString *)columnTypeForObjectStorage
+{
+ return kSQLiteColumnTypeReal;
+}
++ (BOOL)shouldBeStoredInBlob
+{
+ return NO;
+}
+@end
94 external_libs/ObjectiveRecord/NSObject-SQLitePersistence.h
@@ -0,0 +1,94 @@
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#define kSQLiteColumnTypeText @"TEXT"
+#define kSQLIteColumnTypeInteger @"INTEGER"
+#define kSQLiteColumnTypeReal @"REAL"
+#define kSQLiteColumnTypeBlob @"BLOB"
+#define kSQLiteColumnTypeNULL @"NULL"
+
+#import <Foundation/Foundation.h>
+@protocol SQLitePersistence
+
+/*!
+ This protocol should be implemented by any object that needs to be stored in a database as a single column. This protocol is not for objects that will be persisted as a table, but only those that need to be persisted inside a column of a table. This is primarily for objects that store numbers, text, dates, and other values that can easily be represented in a column of a database table. For more complex objects, subclass SQLitePersistentObject
+ */
+
+@required
+/*!
+ This method is used to indicate whether this data object can be stored in a column of a SQLite3 table
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns the SQL data type to use to store this object in a SQLite3 database. Must be one of kSQLiteColumnTypeText, kSQLIteColumnTypeInteger, kSQLiteColumnTypeReal, kSQLiteColumnTypeBlob
+ */
++ (NSString *)columnTypeForObjectStorage;
++ (BOOL)shouldBeStoredInBlob;
+
+@optional
+/*!
+ This method needs to be implemented only if a class returns YES to shouldBeStoredInBlob. Inits an object from a blob.
+ */
++ (id)objectWithSqlColumnRepresentation:(NSString *)columnData;
+/*!
+ This method needs to be implemented only if this class returns YES to shouldBeStoredInBlob. Returns an NSData containing the data to go in the blob. This method must be implemented by objects that return YES in canBeStoredInSQLite and YES in shouldBeStoredInBlob.
+ */
+- (NSData *)sqlBlobRepresentationOfSelf;
+
+/*!
+ This method returns an autoreleased object from column data pulled from the database. This is the reverse to sqlColumnRepresentationOfSelf and needs to be able to create a data from whatever is returned by that method. This method must be implemented by objects that return YES in canBeStoredInSQLite but YES in shouldBeStoredInBlob. */
++ (id)objectWithSQLBlobRepresentation:(NSData *)data;
+
+/*!
+ This method returns a string that holds this object's data and which can be used to re-constitute the object using objectWithSqlColumnRepresentation:. This method must be implemented by objects that return YES in canBeStoredInSQLite but NO in shouldBeStoredInBlob.
+ */
+- (NSString *)sqlColumnRepresentationOfSelf;
+
+
+@end
+
+/*!
+ This category on NSObject provides a basic mechanism for objects to be written into the database as the column of a table. The methods in this category should be overwritten by any class that needs to be stored in the database, as the method used here is to archive the object into an an NSData instance, then Base64 the archived data and store it in a TEXT column. This method is inefficient and does not allow meaningful searches on the column, but it does provide a mechanism to allow any object that implements NSCoding to be stored in the database.
+
+ NOTE: Investigate using a BLOB instead of BASE64 encoded TEXT for the default implementation.
+ */
+@interface NSObject(SQLitePersistence)
+/*!
+ This method is used to indicate whether this data object can be stored in a column of a SQLite3 table. This default implementation returns YES if this object conforms to NSCoding.
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns the SQL data type to use to store this object in a SQLite3 database. This default implementation returns TEXT, since the object will be stored BASE64 encoded.
+ */
++ (NSString *)columnTypeForObjectStorage;
+
++ (BOOL)shouldBeStoredInBlob;
+- (NSData *)sqlBlobRepresentationOfSelf;
++ (id)objectWithSQLBlobRepresentation:(NSData *)data;
+
+
+
+/*
+ * Foundation methods missing from iPhone
+ */
++ (NSString *)className;
+- (NSString *)className;
+
+
+@end
66 external_libs/ObjectiveRecord/NSObject-SQLitePersistence.m
@@ -0,0 +1,66 @@
+//
+// NSObject-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import "NSObject-SQLitePersistence.h"
+@implementation NSObject(SQLitePersistence)
+
++ (BOOL)canBeStoredInSQLite;
+{
+ return [self conformsToProtocol:@protocol(NSCoding)];
+}
++ (NSString *)columnTypeForObjectStorage
+{
+ return kSQLiteColumnTypeBlob;
+}
+- (NSData *)sqlBlobRepresentationOfSelf
+{
+ NSMutableData *data = [[NSMutableData alloc] init];
+ NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
+ [archiver encodeObject:self forKey:[self className]];
+ [archiver finishEncoding];
+ [archiver release];
+ return [data autorelease];
+}
++ (BOOL)shouldBeStoredInBlob
+{
+ return YES;
+}
++ (id)objectWithSQLBlobRepresentation:(NSData *)data;
+{
+ if (data == nil || [data length] == 0)
+ return nil;
+
+ NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
+ id ret = [unarchiver decodeObjectForKey:[self className]];
+ [unarchiver finishDecoding];
+ [unarchiver release];
+ [data release];
+
+ return ret;
+}
+
++ (NSString *)className {
+ return NSStringFromClass([self class]);
+}
+- (NSString *)className {
+ return [[self class] className];
+}
+
+@end
27 external_libs/ObjectiveRecord/NSString-SQLiteColumnName.h
@@ -0,0 +1,27 @@
+//
+// NSString-SQLiteColumnName.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+
+
+@interface NSString(SQLiteColumnName)
+- (NSString *)stringAsSQLColumnName;
+- (NSString *)stringAsPropertyString;
+@end
61 external_libs/ObjectiveRecord/NSString-SQLiteColumnName.m
@@ -0,0 +1,61 @@
+//
+// NSString-SQLiteColumnName.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import "NSString-SQLiteColumnName.h"
+
+
+@implementation NSString(SQLiteColumnName)
+- (NSString *)stringAsSQLColumnName
+{
+ NSMutableString *ret = [NSMutableString string];
+ for (int i=0; i < [self length]; i++)
+ {
+ NSRange sRange = NSMakeRange(i,1);
+ NSString *oneChar = [self substringWithRange:sRange];
+ if ([oneChar isEqualToString:[oneChar uppercaseString]] && i > 0)
+ [ret appendFormat:@"_%@", [oneChar lowercaseString]];
+ else
+ [ret appendString:[oneChar lowercaseString]];
+ }
+ return ret;
+}
+- (NSString *)stringAsPropertyString
+{
+ BOOL lastWasUnderscore = NO;
+ NSMutableString *ret = [NSMutableString string];
+ for (int i=0; i < [self length]; i++)
+ {
+ NSRange sRange = NSMakeRange(i,1);
+ NSString *oneChar = [self substringWithRange:sRange];
+ if ([oneChar isEqualToString:@"_"])
+ lastWasUnderscore = YES;
+ else
+ {
+ if (lastWasUnderscore)
+ [ret appendString:[oneChar uppercaseString]];
+ else
+ [ret appendString:oneChar];
+
+ lastWasUnderscore = NO;
+ }
+ }
+ return ret;
+}
+@end
46 external_libs/ObjectiveRecord/NSString-SQLitePersistence.h
@@ -0,0 +1,46 @@
+//
+// NSString-SQLitePersistence.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+#import "NSObject-SQLitePersistence.h"
+
+@interface NSString(SQLitePersistence) <SQLitePersistence>
+/*!
+ This method initializes an NSString from TEXT colum data pulled from the database.
+ */
++ (id)objectWithSqlColumnRepresentation:(NSString *)columnData;
+
+/*!
+ This method returns self.
+ */
+- (NSString *)sqlColumnRepresentationOfSelf;
+
+/*!
+ Returns YES to indicate it can be stored in a column of a database
+ */
++ (BOOL)canBeStoredInSQLite;
+
+/*!
+ Returns TEXT to inidicate this object can be stored in a TEXT column
+ */
++ (NSString *)columnTypeForObjectStorage;
+
++ (BOOL)shouldBeStoredInBlob;
+@end
44 external_libs/ObjectiveRecord/NSString-SQLitePersistence.m
@@ -0,0 +1,44 @@
+//
+// NSString-SQLitePersistence.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import "NSString-SQLitePersistence.h"
+
+
+@implementation NSString(SQLitePersistence)
++ (id)objectWithSqlColumnRepresentation:(NSString *)columnData
+{
+ return columnData;
+}
+- (NSString *)sqlColumnRepresentationOfSelf
+{
+ return self;
+}
++ (BOOL)canBeStoredInSQLite;
+{
+ return YES;
+}
++ (NSString *)columnTypeForObjectStorage
+{
+ return kSQLiteColumnTypeText;
+}
++ (BOOL)shouldBeStoredInBlob
+{
+ return NO;
+}
+@end
27 external_libs/ObjectiveRecord/NSString-UppercaseFirst.h
@@ -0,0 +1,27 @@
+//
+// NSString-UppercaseFirst.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <UIKit/UIKit.h>
+
+
+@interface NSString(UppercaseFirst)
+- (NSString *) stringByUppercasingFirstLetter;
+- (NSString *) stringByLowercasingFirstLetter;
+@end
37 external_libs/ObjectiveRecord/NSString-UppercaseFirst.m
@@ -0,0 +1,37 @@
+//
+// NSString-UppercaseFirst.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+#import "NSString-UppercaseFirst.h"
+
+
+@implementation NSString(UppercaseFirst)
+- (NSString *) stringByUppercasingFirstLetter
+{
+ NSRange firstLetterRange = NSMakeRange(0,1);
+ NSRange restOfWordRange = NSMakeRange(1,[self length]-1);
+ return [NSString stringWithFormat:@"%@%@", [[self substringWithRange:firstLetterRange] uppercaseString], [self substringWithRange:restOfWordRange]];
+
+}
+- (NSString *) stringByLowercasingFirstLetter
+{
+ NSRange firstLetterRange = NSMakeRange(0,1);
+ NSRange restOfWordRange = NSMakeRange(1,[self length]-1);
+ return [NSString stringWithFormat:@"%@%@", [[self substringWithRange:firstLetterRange] lowercaseString], [self substringWithRange:restOfWordRange]];
+}
+@end
15 external_libs/ObjectiveRecord/ORCDataChangedDelegate.h
@@ -0,0 +1,15 @@
+//
+// ORCDataChangedDelegate.h
+// objectivesync
+//
+// Created by vickeryj on 1/27/09.
+// Copyright 2009 Joshua Vickery. All rights reserved.
+//
+
+
+
+@protocol ORCDataChangedDelegate
+
+- (void) objectOfClass:(Class)cls createdWithPk:(int)pk;
+
+@end
40 external_libs/ObjectiveRecord/SQLiteInstanceManager.h
@@ -0,0 +1,40 @@
+//
+// SQLiteInstanceManager.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <UIKit/UIKit.h>
+#import "/usr/include/sqlite3.h"
+#import <objc/runtime.h>
+
+@interface SQLiteInstanceManager : NSObject {
+
+ @private
+ SQLiteInstanceManager *singleton;
+ NSString *databaseFilepath;
+ sqlite3 *database;
+}
++ (id)sharedManager;
+
+- (NSArray *)executeQuery:(NSString *)sql;
+- (NSArray *)executeQuery:(NSString *)sql substitutions:(NSDictionary *)substitutions;
+- (void)beginTransaction;
+- (void)commitTransaction;
+- (void)rollbackTransaction;
+
+@end
280 external_libs/ObjectiveRecord/SQLiteInstanceManager.m
@@ -0,0 +1,280 @@
+//
+// SQLiteInstanceManager.m
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import "SQLiteInstanceManager.h"
+#import "NSDate-SQLitePersistence.h"
+
+#ifndef debugLog(...)
+ #define debugLog(...)
+#endif
+
+static SQLiteInstanceManager *sharedSQLiteManager = nil;
+
+#pragma mark Private Method Declarations
+@interface SQLiteInstanceManager (private)
+- (NSString *)databaseFilepath;
+@end
+
+@implementation SQLiteInstanceManager
+#pragma mark -
+#pragma mark Singleton Methods
++ (id)sharedManager
+{
+ @synchronized(self)
+ {
+ if (sharedSQLiteManager == nil)
+ [[self alloc] init];
+ }
+ return sharedSQLiteManager;
+}
++ (id)allocWithZone:(NSZone *)zone
+{
+ @synchronized(self) {
+ if (sharedSQLiteManager == nil)
+ {
+ sharedSQLiteManager = [super allocWithZone:zone];
+ return sharedSQLiteManager;
+ }
+ }
+ return nil;
+}
+- (id)copyWithZone:(NSZone *)zone
+{
+ return self;
+}
+- (id)retain
+{
+ return self;
+}
+- (unsigned)retainCount
+{
+ return UINT_MAX; //denotes an object that cannot be released
+}
+- (void)release
+{
+ // never release
+}
+- (id)autorelease
+{
+ return self;
+}
+#pragma mark -
+-(sqlite3 *)database
+{
+ static BOOL first = YES;
+
+ if (first || database == NULL)
+ {
+ first = NO;
+ if (!sqlite3_open([[self databaseFilepath] UTF8String], &database) == SQLITE_OK)
+ {
+ // Even though the open failed, call close to properly clean up resources.
+ NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
+ sqlite3_close(database);
+ }
+ char *errorMsg = 0;
+ if (sqlite3_exec(database, "PRAGMA encoding = \"UTF-8\"", NULL, NULL, &errorMsg) != SQLITE_OK) {
+ NSAssert1(0, @"Failed to switch encoding to UTF-8 with message '%s'.", errorMsg);
+ sqlite3_free(errorMsg);
+ }
+ }
+ return database;
+}
+
+- (NSArray *)columnsForQuery:(sqlite3_stmt *)query
+{
+ int columnCount = sqlite3_column_count(query);
+ if(columnCount <= 0)
+ return nil;
+
+ NSMutableArray *columnNames = [NSMutableArray array];
+ for(int i = 0; i < columnCount; ++i)
+ {
+ const char *name;
+ name = sqlite3_column_name(query, i);
+ [columnNames addObject:[NSString stringWithUTF8String:name]];
+ }
+ return columnNames;
+}
+
+
+// You have to step through the *query yourself,
+- (id)valueForColumn:(unsigned int)colIndex query:(sqlite3_stmt *)query
+{
+ int columnType = sqlite3_column_type(query, colIndex);
+ switch(columnType)
+ {
+ case SQLITE_INTEGER:
+ return [NSNumber numberWithInt:sqlite3_column_int(query, colIndex)];
+ break;
+ case SQLITE_FLOAT:
+ return [NSNumber numberWithDouble:sqlite3_column_double(query, colIndex)];
+ break;
+ case SQLITE_BLOB:
+ return [NSData dataWithBytes:sqlite3_column_blob(query, colIndex)
+ length:sqlite3_column_bytes(query, colIndex)];
+ break;
+ case SQLITE_NULL:
+ return [NSNull null];
+ break;
+ case SQLITE_TEXT:
+ return [NSString stringWithUTF8String:(const char *)sqlite3_column_text(query, colIndex)];
+ break;
+ default:
+ // It really shouldn't ever come to this.
+ break;
+ }
+ return nil;
+}
+
+- (void)beginTransaction {
+ [self executeQuery:@"BEGIN"];
+}
+- (void)commitTransaction {
+ [self executeQuery:@"COMMIT"];
+}
+- (void)rollbackTransaction {
+ [self executeQuery:@"ROLLBACK"];
+}
+
+- (NSArray *)executeQuery:(NSString *)sql {
+ return [self executeQuery:sql substitutions:nil];
+}
+
+- (NSArray *)executeQuery:(NSString *)sql substitutions:(NSDictionary *)substitutions {
+ @synchronized(self) {
+ sqlite3 *db = [self database];
+
+ sqlite3_stmt *stmt;
+ const char *errMsg;
+ int err = sqlite3_prepare_v2(db, [sql UTF8String],
+ [sql lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
+ &stmt, &errMsg);
+
+ if(err != SQLITE_OK || stmt == NULL)
+ {
+ NSLog(@"ERROR Couldn't prepare(%@), %@", sql, [NSString stringWithUTF8String:sqlite3_errmsg(db)]);
+ return nil;
+ }
+ else {
+ debugLog(sql);
+ }
+
+ NSArray *columnNames = [self columnsForQuery:stmt];
+
+ for(int i = 1; i <= sqlite3_bind_parameter_count(stmt); ++i)
+ {
+ const char *keyCstring = sqlite3_bind_parameter_name(stmt, i);
+ if(!keyCstring)
+ continue;
+
+ NSString *key = [[NSString stringWithUTF8String:keyCstring] stringByReplacingOccurrencesOfString:@":" withString:@""];
+ id sub = [substitutions objectForKey:key];
+ if(!sub)
+ continue;
+ if([sub isMemberOfClass:[NSString class]] || [[sub className] isEqualToString:@"NSCFString"])
+ sqlite3_bind_text(stmt, i, [sub UTF8String], -1, SQLITE_TRANSIENT);
+ else if([sub isMemberOfClass:[NSData class]])
+ sqlite3_bind_blob(stmt, i, [sub bytes], [sub length], SQLITE_STATIC); // Not sure if we should make this transient
+ else if([[sub className] isEqualToString:@"NSCFNumber"])
+ sqlite3_bind_double(stmt, i, [sub doubleValue]);
+ else if([sub isMemberOfClass:[NSNull class]])
+ sqlite3_bind_null(stmt, i);
+ else if([sub isKindOfClass:[NSDate class]])
+ sqlite3_bind_text(stmt, i, [[sub sqlColumnRepresentationOfSelf] UTF8String], -1, NULL);
+ else
+ NSLog(@"ERROR SQLiteInstanceManager doesn't know how to handle this type of object: %@ class: %@", sub, [sub className]);
+ }
+
+
+ NSMutableArray *result = [NSMutableArray array];
+ NSMutableDictionary *columns;
+ int resultCode = 0;
+ while((resultCode = sqlite3_step(stmt)) != SQLITE_DONE)
+ {
+ if(resultCode == SQLITE_ERROR || err == SQLITE_MISUSE)
+ {
+ NSLog(@"ERROR while running \"%@\" %@", sql, [NSString stringWithUTF8String:sqlite3_errmsg(db)]);
+ break;
+ }
+ else if(resultCode == SQLITE_ROW)
+ {
+ // construct the dictionary for the row
+ columns = [NSMutableDictionary dictionary];
+ int i = 0;
+ for (NSString *columnName in columnNames)
+ {
+ id value = [self valueForColumn:i query:stmt];
+ if ([NSNull null] != value) {
+ [columns setObject:value forKey:columnName];
+ }
+ ++i;
+ }
+ [result addObject:columns];
+ }
+ }
+
+ sqlite3_finalize(stmt);
+
+ return result;
+ }
+ return nil;
+}
+
+#pragma mark -
+- (void)dealloc
+{
+ [databaseFilepath release];
+ [super dealloc];
+}
+#pragma mark -
+#pragma mark Private Methods
+- (NSString *)databaseFilepath
+{
+ if (databaseFilepath == nil)
+ {
+ NSMutableString *ret = [NSMutableString string];
+ NSString *appName = [[NSProcessInfo processInfo] processName];
+ for (int i = 0; i < [appName length]; i++)
+ {
+ NSRange range = NSMakeRange(i, 1);
+ NSString *oneChar = [appName substringWithRange:range];
+ if (![oneChar isEqualToString:@" "])
+ [ret appendString:[oneChar lowercaseString]];
+ }
+#if (TARGET_OS_MAC && ! (TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR))
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
+ NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
+ NSString *saveDirectory = [basePath stringByAppendingPathComponent:appName];
+#else
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *saveDirectory = [paths objectAtIndex:0];
+#endif
+ NSString *saveFileName = [NSString stringWithFormat:@"%@.sqlite3", ret];
+ NSString *filepath = [saveDirectory stringByAppendingPathComponent:saveFileName];
+
+ databaseFilepath = [filepath retain];
+ debugLog(databaseFilepath);
+ if (![[NSFileManager defaultManager] fileExistsAtPath:saveDirectory])
+ [[NSFileManager defaultManager] createDirectoryAtPath:saveDirectory withIntermediateDirectories:YES attributes:nil error:nil];
+ }
+ return databaseFilepath;
+}
+@end
123 external_libs/ObjectiveRecord/SQLitePersistentObject.h
@@ -0,0 +1,123 @@
+//
+// SQLitePersistentObject.h
+// ----------------------------------------------------------------------
+// Part of the SQLite Persistent Objects for Cocoa and Cocoa Touch
+//
+// (c) 2008 Jeff LaMarche (jeff_Lamarche@mac.com)
+// ----------------------------------------------------------------------
+// This code may be used without restriction in any software, commercial,
+// free, or otherwise. There are no attribution requirements, and no
+// requirement that you distribute your changes, although bugfixes and
+// enhancements are welcome.
+//
+// If you do choose to re-distribute the source code, you must retain the
+// copyright notice and this license information. I also request that you
+// place comments in to identify your changes.
+//
+// For information on how to use these classes, take a look at the
+// included eadme.txt file
+// ----------------------------------------------------------------------
+
+#import <Foundation/Foundation.h>
+#import "/usr/include/sqlite3.h"
+#import <objc/runtime.h>
+#import "ORCDataChangedDelegate.h"
+
+#define isNSArrayType(x) ([x isEqualToString:@"NSArray"] || [x isEqualToString:@"NSMutableArray"])
+#define isNSDictionaryType(x) ([x isEqualToString:@"NSDictionary"] || [x isEqualToString:@"NSMutableDictionary"])
+#define isNSSetType(x) ([x isEqualToString:@"NSSet"] || [x isEqualToString:@"NSMutableSet"])
+
+/*!
+ Any class that subclasses this class can have their properties automatically persisted into a sqlite database. There are some limits - currently certain property types aren't supported like void *, char *, structs and unions. Anything that doesn't work correctly with Key Value Coding will not work with this. Ordinary scalars (ints, floats, etc) will be converted to NSNumber, as will BOOL.
+
+ SQLite is very good about converting types, so you can search on a number field passing in a number in a string, and can search on a string field by passing in a number. The only limitation we place on the search methods is that we don't allow searching on blobs, which is simply for performance reasons.
+
+ */
+// TODO: Look at marking object "dirty" when changes are made, and if it's not dirty, save becomes a no-op.
+
+@interface SQLitePersistentObject : NSObject {
+
+ NSInteger pk;
+
+}
+/*!
+ Returns the name of the table that this object will use to save its data
+ */
++ (NSString *)tableName;
+
+/*!
+ Find by criteria lets you specify the SQL conditions that will be used. The string passed in should start with the word WHERE. So, to search for a value with a pk value of 1, you would pass in @"WHERE pk = 1". When comparing to strings, the string comparison must be in single-quotes like this @"WHERE name = 'smith'".
+ */
++(NSArray *)findByCriteria:(NSString *)criteriaString;
++(SQLitePersistentObject *)findFirstByCriteria:(NSString *)criteriaString;
++(SQLitePersistentObject *)findByPK:(int)inPk;
+
++(void)deleteByCriteria:(NSString *)criteriaString;
+
+/*!
+ This method should be overridden by subclasses in order to specify performance indices on the underyling table.
+ @result Should return an array of arrays. Each array represents one index, and should contain a list of the properties that the index should be created on, in the order the database should use to create it. This is case sensitive, and the values must match the value of property names
+ */
++(NSArray *)indices;
+
+/*!
+ Deletes this object's corresponding row from the database table. This version does NOT cascade to child objects in other tables.
+ */
+-(void)deleteObject;
+
+/*!
+ This is just a convenience routine; in several places we have to iterate through the properties and take some action based
+ on their type. This method creates an array with all the property names and their types in a dictionary. The values for
+ the encoded types will be one of:
+
+ c A char
+ i An int
+ s A short
+ l A long
+ q A long long
+ C An unsigned char
+ I An unsigned int
+ S An unsigned short
+ L An unsigned long
+ Q An unsigned long long
+ f A float
+ d A double
+ B A C++ bool or a C99 _Bool
+ v A void
+ * A character string (char *)
+ @ An object (whether statically typed or typed id)
+ # A class object (Class)
+ : A method selector (SEL)
+ [array type] An array
+ {name=type...} A structure
+ (name=type...) A union
+ bnum A bit field of num bits
+ ^type A pointer to type
+ ? An unknown type (among other things, this code is used for function pointers)
+
+ Currently, the following properties cannot be persisted using this class: C, c, v, #, :, [array type], *, {name=type...}, (name=type...), bnum, ^type, or ?
+ TODO: Look at finding ways to allow people to use some or all of the currently unsupported types... we could probably use sizeof to store the structs and unions maybe??.
+ TODO: Look at overriding valueForUndefinedKey: to handle the char, char * and unsigned char property types - valueForKey: doesn't return anything for these, so currently they do not work.
+ */
++ (NSDictionary *)propertiesWithEncodedTypes;
+
++ (void)setDataChangedDelegate:(id<ORCDataChangedDelegate>)delegate;
+
+/*!
+ Indicates whether this object has ever been saved to the database. It does not indicate that the data matches what's in the database, just that there is a corresponding row
+ */
+-(BOOL) existsInDB;
+
+/*!
+ Saves this object's current data to the database. If it has never been saved before, it will assign a primary key value based on the database contents. Scalar values (ints, floats, doubles, etc.) will be stored in appropriate database columns, objects will be stored using the SQLitePersistence protocol methods - objects that don't implement that protocol will be archived into the database. Collection clases will be stored in child cross-reference tables that serve double duty. Any object they contain that is a subclass of SQLItePersistentObject will be stored as a foreign key to the appropriate table, otherwise objects will be stored in a column according to SQLitePersistence. Currently, collection classes inside collection classes are simply serialized into the x-ref table, which works, but is not the most efficient means.
+
+ //TODO: Look at adding recursion of some form to allow collection objects within collection objects to be stored in a normalized fashion
+ */