Skip to content
Browse files

AWS SDK for iOS 1.4.0

  • Loading branch information...
1 parent 4fb8673 commit d1480b647b381d948a3546f8ead72e821bd3ecc1 Yosuke Matsuda committed Aug 23, 2012
Showing with 5,538 additions and 3,658 deletions.
  1. +5 −19 samples/AWSPersistence_Locations2/Classes/AmazonClientManager.m
  2. +0 −2 samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.m
  3. +3 −1 samples/AWSPersistence_Locations2/Classes/LocationsAppDelegate.m
  4. +88 −71 samples/AWSPersistence_Locations2/Classes/Utilities.m
  5. +31 −0 samples/AWSPersistence_Locations2/CoreData.html
  6. +1 −1 samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.h
  7. +8 −13 samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.m
  8. +3 −0 samples/DynamoDB_UserPreference/UserPreference/AppDelegate.m
  9. +84 −100 samples/DynamoDB_UserPreference/UserPreference/DynamoDBManager.m
  10. +14 −3 samples/DynamoDB_UserPreference/UserPreference/UserPreference-Prefix.pch
  11. +1 −1 samples/DynamoDB_UserPreference/UserPreference/WelcomeViewController.m
  12. +16 −15 samples/DynamoDB_UserPreference/UserPreference/main.m
  13. +3 −1 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoAppDelegate.m
  14. +7 −7 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddBucketViewController.m
  15. +10 −10 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddObjectViewController.m
  16. +17 −20 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageUploader.m
  17. +36 −41 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/BucketList.m
  18. +51 −49 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectListing.m
  19. +8 −9 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectViewController.m
  20. +17 −16 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3AsyncViewController.m
  21. +38 −32 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3NSOperationDemoViewController.m
  22. +21 −23 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/DomainList.m
  23. +23 −23 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemListing.m
  24. +21 −21 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemViewController.m
  25. +44 −46 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbAsyncViewController.m
  26. +21 −20 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SNS/TopicList.m
  27. +7 −8 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/AddQueue.m
  28. +31 −35 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/MessageList.m
  29. +42 −50 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/QueueList.m
  30. +7 −8 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/SendMessage.m
  31. +3 −1 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVMAppDelegate.m
  32. +1 −1 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/AmazonClientManager.h
  33. +3 −1 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/AmazonClientManager.m
  34. +8 −9 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddBucketViewController.m
  35. +11 −13 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddObjectViewController.m
  36. +41 −64 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/BucketList.m
  37. +84 −88 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/ObjectListing.m
  38. +9 −11 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/ObjectViewController.m
  39. +36 −32 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/S3AsyncViewController.m
  40. +24 −26 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SDB/DomainList.m
  41. +25 −26 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SDB/ItemListing.m
  42. +23 −24 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SDB/ItemViewController.m
  43. +47 −52 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SDB/SdbAsyncViewController.m
  44. +23 −23 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SNS/TopicList.m
  45. +8 −10 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SQS/AddQueue.m
  46. +35 −39 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SQS/MessageList.m
  47. +44 −61 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SQS/QueueList.m
  48. +8 −11 samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/SQS/SendMessage.m
  49. +1 −1 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/AmazonClientManager.h
  50. +3 −1 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/AmazonClientManager.m
  51. +7 −9 ...es/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/AddBucketViewController.m
  52. +11 −12 ...es/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/AddObjectViewController.m
  53. +37 −48 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/BucketList.m
  54. +76 −84 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/ObjectListing.m
  55. +9 −11 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/ObjectViewController.m
  56. +25 −18 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/S3/S3AsyncViewController.m
  57. +25 −26 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SDB/DomainList.m
  58. +25 −26 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SDB/ItemListing.m
  59. +24 −24 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SDB/ItemViewController.m
  60. +48 −52 ...es/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SDB/SdbAsyncViewController.m
  61. +23 −23 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SNS/TopicList.m
  62. +8 −10 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SQS/AddQueue.m
  63. +37 −41 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SQS/MessageList.m
  64. +46 −62 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SQS/QueueList.m
  65. +8 −10 samples/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/SQS/SendMessage.m
  66. +3 −0 ..._SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/TVMClient/AmazonKeyChainWrapper.h
  67. +20 −0 ..._SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/TVMClient/AmazonKeyChainWrapper.m
  68. +1 −0 ...les/S3_SimpleDB_SNS_SQS_DemoTVMIdentity/AWSiOSDemoTVMIdentity/Classes/TVMClient/AmazonTVMClient.m
  69. +3 −0 samples/S3_Uploader/S3Uploader/S3UploaderAppDelegate.m
  70. +46 −37 samples/S3_Uploader/S3Uploader/S3UploaderViewController.m
  71. +2 −1 samples/SES_FeedbackForm/FeedbackForm/AppDelegate.m
  72. +27 −28 samples/SES_FeedbackForm/FeedbackForm/SESManager.m
  73. +155 −162 samples/SNS_SQS_MessageBoard/MessageBoard/MessageBoard.m
  74. +3 −0 samples/SNS_SQS_MessageBoard/MessageBoard/Message_BoardAppDelegate.m
  75. +88 −88 samples/SimpleDB_HighScores/HighScores/HighScoreList.m
  76. +3 −1 samples/SimpleDB_HighScores/HighScores/HighScoresAppDelegate.m
  77. +430 −404 src-persistence/AWSPersistenceDynamoDBIncrementalStore.m
  78. +1,157 −1,069 src/AWSiOSSDK.xcodeproj/project.pbxproj
  79. +1 −0 src/AWSiOSSDK_Prefix.pch
  80. +50 −21 src/Amazon.DynamoDB/DynamoDBResponse.m
  81. +42 −11 src/Amazon.DynamoDB/DynamoDBWebServiceClient.m
  82. +35 −0 src/Amazon.DynamoDB/Model/DynamoDBAttributeValue.m
  83. +11 −0 src/Amazon.DynamoDB/Model/DynamoDBAttributeValueUnmarshaller.m
  84. +33 −0 src/Amazon.DynamoDB/Model/DynamoDBBatchGetItemRequestMarshaller.m
  85. +49 −0 src/Amazon.DynamoDB/Model/DynamoDBBatchWriteItemRequestMarshaller.m
  86. +1 −0 src/Amazon.DynamoDB/Model/DynamoDBCreateTableRequestMarshaller.m
  87. +49 −0 src/Amazon.DynamoDB/Model/DynamoDBDeleteItemRequestMarshaller.m
  88. +1 −0 src/Amazon.DynamoDB/Model/DynamoDBDeleteTableRequestMarshaller.m
  89. +1 −0 src/Amazon.DynamoDB/Model/DynamoDBDescribeTableRequestMarshaller.m
  90. +33 −0 src/Amazon.DynamoDB/Model/DynamoDBGetItemRequestMarshaller.m
  91. +1 −0 src/Amazon.DynamoDB/Model/DynamoDBListTablesRequestMarshaller.m
  92. +33 −0 src/Amazon.DynamoDB/Model/DynamoDBPutItemRequestMarshaller.m
  93. +65 −0 src/Amazon.DynamoDB/Model/DynamoDBQueryRequestMarshaller.m
  94. +49 −0 src/Amazon.DynamoDB/Model/DynamoDBScanRequestMarshaller.m
  95. +65 −0 src/Amazon.DynamoDB/Model/DynamoDBUpdateItemRequestMarshaller.m
  96. +1 −0 src/Amazon.DynamoDB/Model/DynamoDBUpdateTableRequestMarshaller.m
  97. +56 −9 src/Amazon.Runtime/AmazonAbstractWebServiceClient.m
  98. +3 −1 src/Amazon.Runtime/AmazonAuthUtils.m
  99. +25 −9 src/Amazon.Runtime/AmazonClientException.m
  100. +117 −0 src/Amazon.Runtime/AmazonErrorHandler.m
  101. +1 −1 src/Amazon.Runtime/AmazonMD5Util.m
  102. +4 −2 src/Amazon.Runtime/AmazonSDKUtil.m
  103. +30 −22 src/Amazon.Runtime/AmazonServiceException.m
  104. +5 −0 src/Amazon.Runtime/AmazonServiceRequest.m
  105. +56 −25 src/Amazon.Runtime/AmazonServiceResponse.m
  106. +122 −69 src/Amazon.S3/AmazonS3Client.m
  107. +10 −9 src/Amazon.S3/Model/S3BucketNameUtilities.m
  108. +51 −0 src/Amazon.S3/Model/S3BucketTagSet.m
  109. +79 −0 src/Amazon.S3/Model/S3BucketTagSetUnmarshaller.m
  110. +48 −0 src/Amazon.S3/Model/S3BucketTaggingConfiguration.m
  111. +51 −0 src/Amazon.S3/Model/S3BucketTaggingConfigurationUnmarshaller.m
  112. +1 −1 src/Amazon.S3/Model/S3CopyPartRequest.m
  113. +12 −1 src/Amazon.S3/Model/S3CreateBucketRequest.m
  114. +14 −4 src/Amazon.S3/Model/S3DeleteBucketRequest.m
  115. +47 −0 src/Amazon.S3/Model/S3DeleteBucketTaggingRequest.m
  116. +20 −0 src/Amazon.S3/Model/S3DeleteBucketTaggingResponse.m
  117. +47 −0 src/Amazon.S3/Model/S3GetBucketTaggingRequest.m
  118. +37 −0 src/Amazon.S3/Model/S3GetBucketTaggingResponse.m
  119. +20 −4 src/Amazon.S3/Model/S3GetObjectRequest.m
  120. +21 −17 src/Amazon.S3/Model/S3GetPreSignedURLRequest.m
  121. +2 −2 src/Amazon.S3/Model/S3Grant.m
  122. +10 −2 src/Amazon.S3/Model/S3Grantee.m
  123. +3 −1 src/Amazon.S3/Model/S3ListObjectsResponse.m
  124. +3 −1 src/Amazon.S3/Model/S3ListVersionsResponse.m
  125. +33 −18 src/Amazon.S3/Model/S3PutObjectRequest.m
  126. +9 −9 src/Amazon.S3/Model/S3Region.m
  127. +17 −7 src/Amazon.S3/Model/S3Response.m
  128. +78 −0 src/Amazon.S3/Model/S3SetBucketTaggingRequest.m
  129. +22 −0 src/Amazon.S3/Model/S3SetBucketTaggingResponse.m
  130. +31 −0 src/Resources/CoreData2.html
  131. +1 −1 src/ThirdParty/JSON/SBJsonStreamParser.m
  132. +1 −0 src/include/AmazonAbstractWebServiceClient.h
  133. +9 −1 src/include/AmazonClientException.h
  134. +34 −0 src/include/AmazonErrorHandler.h
  135. +1 −1 src/include/AmazonSDKUtil.h
  136. +11 −10 src/include/AmazonServiceException.h
  137. +7 −1 src/include/AmazonServiceRequest.h
  138. +6 −1 src/include/AmazonServiceResponse.h
  139. +35 −0 src/include/DynamoDB/DynamoDBAttributeValue.h
  140. +4 −2 src/include/DynamoDB/DynamoDBAttributeValueUpdate.h
  141. +1 −1 src/include/DynamoDB/DynamoDBKeySchemaElement.h
  142. +3 −0 src/include/DynamoDB/DynamoDBQueryRequestMarshaller.h
  143. +78 −8 src/include/S3/AmazonS3Client.h
  144. +2 −1 src/include/S3/S3BucketNameUtilities.h
  145. +30 −0 src/include/S3/S3BucketTagSet.h
  146. +29 −0 src/include/S3/S3BucketTagSetUnmarshaller.h
  147. +32 −0 src/include/S3/S3BucketTaggingConfiguration.h
  148. +29 −0 src/include/S3/S3BucketTaggingConfigurationUnmarshaller.h
  149. +1 −0 src/include/S3/S3Constants.h
  150. +30 −0 src/include/S3/S3DeleteBucketTaggingRequest.h
  151. +26 −0 src/include/S3/S3DeleteBucketTaggingResponse.h
  152. +30 −0 src/include/S3/S3GetBucketTaggingRequest.h
  153. +31 −0 src/include/S3/S3GetBucketTaggingResponse.h
  154. +37 −0 src/include/S3/S3SetBucketTaggingRequest.h
  155. +23 −0 src/include/S3/S3SetBucketTaggingResponse.h
View
24 samples/AWSPersistence_Locations2/Classes/AmazonClientManager.m
@@ -30,36 +30,22 @@ @implementation AmazonClientManager
+(AmazonDynamoDBClient *)ddb
{
- @try
- {
- [AmazonClientManager validateCredentials];
- return ddb;
- }
- @catch (NSException *exception)
- {
- NSLog(@"Exception: %@", exception);
- }
+ [AmazonClientManager validateCredentials];
+ return ddb;
}
+(AmazonCredentials *)credentials;
{
- @try
- {
- [AmazonClientManager validateCredentials];
- return credentials;
- }
- @catch (NSException *exception)
- {
- NSLog(@"Exception: %@", exception);
- }
+ [AmazonClientManager validateCredentials];
+ return credentials;
}
+(AmazonTVMClient *)tvm
{
if (tvm == nil) {
tvm = [[AmazonTVMClient alloc] initWithEndpoint:TOKEN_VENDING_MACHINE_URL useSSL:USE_SSL];
}
-
+
return tvm;
}
View
2 samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.m
@@ -17,8 +17,6 @@
#import <AWSiOSSDK/AmazonLogger.h>
-
-
NSString *kKeychainAccessKeyIdentifier;
NSString *kKeychainSecretKeyIdentifier;
NSString *kKeychainSecrutiyTokenIdentifier;
View
4 samples/AWSPersistence_Locations2/Classes/LocationsAppDelegate.m
@@ -17,6 +17,7 @@
#import "RootViewController.h"
#import "AmazonClientManager.h"
#import <AWSiOSSDK/AmazonLogger.h>
+#import <AWSiOSSDK/AmazonErrorHandler.h>
@implementation LocationsAppDelegate
@@ -29,13 +30,14 @@ @implementation LocationsAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
-
// Logging Control - Do NOT use logging for non-development builds.
#ifdef DEBUG
[AmazonLogger verboseLogging];
#else
[AmazonLogger turnLoggingOff];
#endif
+
+ [AmazonErrorHandler shouldNotThrowExceptions];
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
View
159 samples/AWSPersistence_Locations2/Classes/Utilities.m
@@ -18,25 +18,6 @@
@implementation Utilities
/**
- * Wait for a table to transition to a given state (i.e. ACTIVE)
- */
-+(void)waitForTable:(NSString *)tableName toTransitionToStatus:(NSString *)toStatus
-{
- NSString *status =@"";
-
- do {
- if (status.length > 0) {
- [NSThread sleepForTimeInterval:15];
- }
- DynamoDBDescribeTableRequest *request = [[DynamoDBDescribeTableRequest alloc] initWithTableName:tableName];
- DynamoDBDescribeTableResponse *response = [[AmazonClientManager ddb] describeTable:request];
-
- status = response.table.tableStatus;
-
- } while (![status isEqualToString:toStatus]);
-}
-
-/**
* Check for existance of tables and create them if necessary
* Returns YES when tables are active
* Returns NO if there was an error
@@ -50,71 +31,107 @@ +(BOOL)setupTables
return NO;
}
- @try {
- //Create Table
- DynamoDBKeySchemaElement *hashKey = [[DynamoDBKeySchemaElement alloc] init];
- hashKey.attributeName = LOCATIONS_KEY;
- hashKey.attributeType = @"S";
-
- DynamoDBKeySchema *keySchema = [[DynamoDBKeySchema alloc] init];
- keySchema.hashKeyElement = hashKey;
-
- DynamoDBProvisionedThroughput *provisionedThroughput = [[DynamoDBProvisionedThroughput alloc] init];
- provisionedThroughput.readCapacityUnits = [NSNumber numberWithInt:10];
- provisionedThroughput.writeCapacityUnits = [NSNumber numberWithInt:5];
-
- DynamoDBCreateTableRequest *ctr = [[DynamoDBCreateTableRequest alloc] init];
- ctr.tableName = LOCATIONS_TABLE;
- ctr.keySchema = keySchema;
- ctr.provisionedThroughput = provisionedThroughput;
-
- DynamoDBCreateTableResponse *ctResponse = [[AmazonClientManager ddb] createTable:ctr];
+ //Create Table
+ DynamoDBKeySchemaElement *hashKey = [[DynamoDBKeySchemaElement alloc] init];
+ hashKey.attributeName = LOCATIONS_KEY;
+ hashKey.attributeType = @"S";
+
+ DynamoDBKeySchema *keySchema = [[DynamoDBKeySchema alloc] init];
+ keySchema.hashKeyElement = hashKey;
+
+ DynamoDBProvisionedThroughput *provisionedThroughput = [[DynamoDBProvisionedThroughput alloc] init];
+ provisionedThroughput.readCapacityUnits = [NSNumber numberWithInt:10];
+ provisionedThroughput.writeCapacityUnits = [NSNumber numberWithInt:5];
+
+ DynamoDBCreateTableRequest *ctr = [[DynamoDBCreateTableRequest alloc] init];
+ ctr.tableName = LOCATIONS_TABLE;
+ ctr.keySchema = keySchema;
+ ctr.provisionedThroughput = provisionedThroughput;
+
+ DynamoDBCreateTableResponse *ctResponse = [[AmazonClientManager ddb] createTable:ctr];
+ if(ctResponse.error == nil)
+ {
NSLog(@"Created %@", ctResponse.tableDescription.tableName);
}
- @catch (DynamoDBResourceInUseException *re) {
- NSLog(@"Table already created");
- }
- @catch (AmazonServiceException *e) {
- NSLog(@"Problem creating table, %@", e);
- return NO;
+ else
+ {
+ NSException *exception = [ctResponse.error.userInfo objectForKey:@"exception"];
+
+ if([exception isKindOfClass:[DynamoDBResourceInUseException class]])
+ {
+ NSLog(@"Table already created");
+ }
+ else
+ {
+ NSLog(@"Problem creating table, %@", ctResponse.error);
+ return NO;
+ }
}
- @try {
- //Create Table
- DynamoDBKeySchemaElement *hashKey = [[DynamoDBKeySchemaElement alloc] init];
- hashKey.attributeName = CHECKINS_KEY;
- hashKey.attributeType = @"S";
-
- DynamoDBKeySchema *keySchema = [[DynamoDBKeySchema alloc] init];
- keySchema.hashKeyElement = hashKey;
-
- DynamoDBProvisionedThroughput *provisionedThroughput = [[DynamoDBProvisionedThroughput alloc] init];
- provisionedThroughput.readCapacityUnits = [NSNumber numberWithInt:10];
- provisionedThroughput.writeCapacityUnits = [NSNumber numberWithInt:5];
-
- DynamoDBCreateTableRequest *ctr = [[DynamoDBCreateTableRequest alloc] init];
- ctr.tableName = CHECKINS_TABLE;
- ctr.keySchema = keySchema;
- ctr.provisionedThroughput = provisionedThroughput;
-
- DynamoDBCreateTableResponse *ctResponse = [[AmazonClientManager ddb] createTable:ctr];
+ //Create Table
+ hashKey = [[DynamoDBKeySchemaElement alloc] init];
+ hashKey.attributeName = CHECKINS_KEY;
+ hashKey.attributeType = @"S";
+
+ keySchema = [[DynamoDBKeySchema alloc] init];
+ keySchema.hashKeyElement = hashKey;
+
+ provisionedThroughput = [[DynamoDBProvisionedThroughput alloc] init];
+ provisionedThroughput.readCapacityUnits = [NSNumber numberWithInt:10];
+ provisionedThroughput.writeCapacityUnits = [NSNumber numberWithInt:5];
+
+ ctr = [[DynamoDBCreateTableRequest alloc] init];
+ ctr.tableName = CHECKINS_TABLE;
+ ctr.keySchema = keySchema;
+ ctr.provisionedThroughput = provisionedThroughput;
+
+ ctResponse = [[AmazonClientManager ddb] createTable:ctr];
+
+ if(ctResponse.error == nil)
+ {
NSLog(@"Created %@", ctResponse.tableDescription.tableName);
}
- @catch (DynamoDBResourceInUseException *re) {
- NSLog(@"Table already created");
- }
- @catch (AmazonServiceException *e) {
- NSLog(@"Problem creating table, %@", e);
- return NO;
- }
+ else
+ {
+ NSException *exception = [ctResponse.error.userInfo objectForKey:@"exception"];
+ if([exception isKindOfClass:[DynamoDBResourceInUseException class]])
+ {
+ NSLog(@"Table already created");
+ }
+ else
+ {
+ NSLog(@"Problem creating table, %@", ctResponse.error);
+ return NO;
+ }
+ }
+
[Utilities waitForTable:LOCATIONS_TABLE toTransitionToStatus:@"ACTIVE"];
[Utilities waitForTable:CHECKINS_TABLE toTransitionToStatus:@"ACTIVE"];
-
+
return YES;
}
/**
+ * Wait for a table to transition to a given state (i.e. ACTIVE)
+ */
++(void)waitForTable:(NSString *)tableName toTransitionToStatus:(NSString *)toStatus
+{
+ NSString *status =@"";
+
+ do {
+ if (status.length > 0) {
+ [NSThread sleepForTimeInterval:15];
+ }
+ DynamoDBDescribeTableRequest *request = [[DynamoDBDescribeTableRequest alloc] initWithTableName:tableName];
+ DynamoDBDescribeTableResponse *response = [[AmazonClientManager ddb] describeTable:request];
+
+ status = response.table.tableStatus;
+
+ } while (![status isEqualToString:toStatus]);
+}
+
+/**
* Generate a unique ID that can be used for objects
*/
+(NSString *)getUUID
View
31 samples/AWSPersistence_Locations2/CoreData.html
@@ -325,6 +325,37 @@
<li>When doing fetches of all objects in a table, the AWS Persistence Framework for Core Data
cannot guarantee that recent objects inserts and deletes will be reflected due to
inconsistent read status. </li>
+ <li>The Persistence Framework does not support sorting because the Amazon
+ DynamoDB scan operation does not sort the result. However, Apple's <a
+ href="https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html">NSManagementObjectContext
+ Class Reference</a> states that "if you fetch some objects, work with
+ them, and then execute a new fetch that includes a superset of those
+ objects, you do not get new instances or update data for the existing
+ objects-you get the existing objects with their current in-memory state."
+ In this situation, Core Data may sort the in-memory objects based on the
+ sort descriptors provided. However, we don't recommend relying on this
+ behavior; instead, you should sort the results in memory when the objects
+ need to be sorted.</li>
+ <li>With the current version of the framework, NSPredicates are limited
+ to only the properties that are mapped to hash keys. Also, when using
+ the framework, your query can specify only one hashKey and only one
+ possible value for that hashKey. Some examples are shown below:
+ <table style="border-collapse:collapse;border:1px solid black;">
+ <tr>
+ <td style="border:1px solid black;">
+ "hashKey1=value1"</td>
+ <td style="border:1px solid black;">
+ supported, one hashKey and one value</td> </tr> <tr>
+ <td style="border:1px solid black;">
+ "hashKey1 = value1 OR hashkey1 = value2"</td>
+ <td style="border:1px solid black;">
+ not supported, one haskKey, but two values</td> </tr> <tr>
+ <td style="border:1px solid black;">
+ "hashKey1 IN (value1, value2)"</td>
+ <td style="border:1px solid black;">
+ not supported, one haskKey, but two values</td> </tr>
+ </table>
+ </li>
</ul>
<h2>Conclusion and Additional Resources</h2>
View
2 samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.h
@@ -23,6 +23,6 @@
}
+(AmazonDynamoDBClient *)ddb;
-+ (void)wipeCredentialsOnAuthError:(NSException *)exception;
++ (void)wipeCredentialsOnAuthError:(NSError *)error;
@end
View
21 samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.m
@@ -28,23 +28,16 @@ @implementation AmazonClientManager
+(AmazonDynamoDBClient *)ddb
{
- @try
- {
- [AmazonClientManager validateCredentials];
- return ddb;
- }
- @catch (NSException *exception)
- {
- NSLog(@"Exception: %@", exception);
- }
+ [AmazonClientManager validateCredentials];
+ return ddb;
}
+(AmazonTVMClient *)tvm
{
if (tvm == nil) {
tvm = [[AmazonTVMClient alloc] initWithEndpoint:TOKEN_VENDING_MACHINE_URL useSSL:USE_SSL];
}
-
+
return tvm;
}
@@ -56,7 +49,7 @@ +(bool)hasCredentials
+(Response *)validateCredentials
{
Response *ableToGetToken = [[[Response alloc] initWithCode:200 andMessage:@"OK"] autorelease];
-
+
if ([AmazonKeyChainWrapper areCredentialsExpired]) {
@synchronized(self)
@@ -87,7 +80,7 @@ +(Response *)validateCredentials
}
}
}
-
+
return ableToGetToken;
}
@@ -110,8 +103,10 @@ +(void)wipeAllCredentials
}
}
-+ (void)wipeCredentialsOnAuthError:(NSException *)exception
++ (void)wipeCredentialsOnAuthError:(NSError *)error
{
+ id exception = [error.userInfo objectForKey:@"exception"];
+
if([exception isKindOfClass:[AmazonServiceException class]])
{
AmazonServiceException *e = (AmazonServiceException *)exception;
View
3 samples/DynamoDB_UserPreference/UserPreference/AppDelegate.m
@@ -16,6 +16,7 @@
#import "AppDelegate.h"
#import "WelcomeViewController.h"
#import <AWSiOSSDK/AmazonLogger.h>
+#import <AWSiOSSDK/AmazonErrorHandler.h>
@implementation AppDelegate
@@ -50,6 +51,8 @@ -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(N
[AmazonLogger turnLoggingOff];
#endif
+ [AmazonErrorHandler shouldNotThrowExceptions];
+
return YES;
}
View
184 samples/DynamoDB_UserPreference/UserPreference/DynamoDBManager.m
@@ -32,23 +32,20 @@ @implementation DynamoDBManager
*/
+(void)createTable
{
- @try
- {
- DynamoDBKeySchemaElement *kse = [[[DynamoDBKeySchemaElement alloc] initWithAttributeName:@"userNo" andAttributeType:@"N"] autorelease];
-
- DynamoDBKeySchema *ks = [[[DynamoDBKeySchema alloc] initWithHashKeyElement:kse] autorelease];
-
- DynamoDBProvisionedThroughput *pt = [[[DynamoDBProvisionedThroughput alloc] init] autorelease];
- pt.readCapacityUnits = [NSNumber numberWithInt:10];
- pt.writeCapacityUnits = [NSNumber numberWithInt:5];
-
- DynamoDBCreateTableRequest *request = [[[DynamoDBCreateTableRequest alloc] initWithTableName:TEST_TABLE_NAME andKeySchema:ks andProvisionedThroughput:pt] autorelease];
- [[AmazonClientManager ddb] createTable:request];
- }
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ DynamoDBKeySchemaElement *kse = [[[DynamoDBKeySchemaElement alloc] initWithAttributeName:@"userNo" andAttributeType:@"N"] autorelease];
+
+ DynamoDBKeySchema *ks = [[[DynamoDBKeySchema alloc] initWithHashKeyElement:kse] autorelease];
+
+ DynamoDBProvisionedThroughput *pt = [[[DynamoDBProvisionedThroughput alloc] init] autorelease];
+ pt.readCapacityUnits = [NSNumber numberWithInt:10];
+ pt.writeCapacityUnits = [NSNumber numberWithInt:5];
+
+ DynamoDBCreateTableRequest *request = [[[DynamoDBCreateTableRequest alloc] initWithTableName:TEST_TABLE_NAME andKeySchema:ks andProvisionedThroughput:pt] autorelease];
+ DynamoDBCreateTableResponse *response = [[AmazonClientManager ddb] createTable:request];
+ if(response.error != nil)
+ {
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
}
}
@@ -57,111 +54,104 @@ +(void)createTable
*/
+(NSString *)getTestTableStatus
{
- @try
+ DynamoDBDescribeTableRequest *request = [[[DynamoDBDescribeTableRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
+ DynamoDBDescribeTableResponse *response = [[AmazonClientManager ddb] describeTable:request];
+ if(response.error != nil)
{
- DynamoDBDescribeTableRequest *request = [[[DynamoDBDescribeTableRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
- DynamoDBDescribeTableResponse *response = [[AmazonClientManager ddb] describeTable:request];
-
- return response.table.tableStatus;
- }
- @catch (DynamoDBResourceNotFoundException *ex) {
+ if([[response.error.userInfo objectForKey:@"exception"] isKindOfClass:[DynamoDBResourceNotFoundException class]])
+ {
+ return nil;
+ }
+
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
+
return nil;
}
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
- }
+
+ return response.table.tableStatus;
}
/*
* Inserts ten users with userNo from 1 to 10 and random names.
*/
+(void)insertUsers
{
- @try
- {
- for (int i = 1; i <= 10; i++)
+ for (int i = 1; i <= 10; i++)
+ {
+ NSMutableDictionary *userDic =
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [[[DynamoDBAttributeValue alloc] initWithN:[NSString stringWithFormat:@"%d", i]] autorelease], @"userNo",
+ [[[DynamoDBAttributeValue alloc] initWithS:[Constants getRandomName]] autorelease], @"firstName",
+ [[[DynamoDBAttributeValue alloc] initWithS:[Constants getRandomName]] autorelease], @"lastName",
+ nil];
+
+ DynamoDBPutItemRequest *request = [[[DynamoDBPutItemRequest alloc] initWithTableName:TEST_TABLE_NAME andItem:userDic] autorelease];
+ DynamoDBPutItemResponse *response = [[AmazonClientManager ddb] putItem:request];
+ if(response.error != nil)
{
- NSMutableDictionary *userDic =
- [NSDictionary dictionaryWithObjectsAndKeys:
- [[[DynamoDBAttributeValue alloc] initWithN:[NSString stringWithFormat:@"%d", i]] autorelease], @"userNo",
- [[[DynamoDBAttributeValue alloc] initWithS:[Constants getRandomName]] autorelease], @"firstName",
- [[[DynamoDBAttributeValue alloc] initWithS:[Constants getRandomName]] autorelease], @"lastName",
- nil];
-
- DynamoDBPutItemRequest *request = [[[DynamoDBPutItemRequest alloc] initWithTableName:TEST_TABLE_NAME andItem:userDic] autorelease];
- [[AmazonClientManager ddb] putItem:request];
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
+
+ break;
}
}
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
- }
}
/*
* Scans the table and returns the list of users.
*/
+(NSMutableArray *)getUserList
{
- @try
+ DynamoDBScanRequest *request = [[[DynamoDBScanRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
+ DynamoDBScanResponse *response = [[AmazonClientManager ddb] scan:request];
+ if(response.error != nil)
{
- DynamoDBScanRequest *request = [[[DynamoDBScanRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
- DynamoDBScanResponse *response = [[AmazonClientManager ddb] scan:request];
-
- return response.items;
- }
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
+
return nil;
}
+
+ return response.items;
}
/*
* Retrieves all of the attribute/value pairs for the specified user.
*/
+(NSMutableDictionary *)getUserInfo:(int)userNo
{
- @try
- {
- DynamoDBGetItemRequest *request = [[[DynamoDBGetItemRequest alloc] initWithTableName:TEST_TABLE_NAME
- andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:
- [[[DynamoDBAttributeValue alloc] initWithN:[NSString stringWithFormat:@"%d", userNo]] autorelease]] autorelease]] autorelease];
- DynamoDBGetItemResponse *response = [[AmazonClientManager ddb] getItem:request];
-
- return response.item;
- }
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ DynamoDBGetItemRequest *request = [[[DynamoDBGetItemRequest alloc] initWithTableName:TEST_TABLE_NAME
+ andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:
+ [[[DynamoDBAttributeValue alloc] initWithN:[NSString stringWithFormat:@"%d", userNo]] autorelease]] autorelease]] autorelease];
+ DynamoDBGetItemResponse *response = [[AmazonClientManager ddb] getItem:request];
+ if(response.error != nil)
+ {
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
+
return nil;
}
+
+ return response.item;
}
/*
* Updates one attribute/value pair for the specified user.
*/
+(void)updateAttributeStringValue:(NSString *)aValue forKey:(NSString *)aKey withPrimaryKey:(DynamoDBAttributeValue *)aPrimaryKey
{
- @try
- {
- DynamoDBAttributeValue *attr = [[[DynamoDBAttributeValue alloc] initWithS:aValue] autorelease];
- DynamoDBAttributeValueUpdate *attrUpdate = [[[DynamoDBAttributeValueUpdate alloc] initWithValue:attr andAction:@"PUT"] autorelease];
-
- DynamoDBUpdateItemRequest *request = [[[DynamoDBUpdateItemRequest alloc] initWithTableName:TEST_TABLE_NAME
- andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:aPrimaryKey] autorelease]
- andAttributeUpdates:[NSMutableDictionary dictionaryWithObject:attrUpdate forKey:aKey]] autorelease];
- [[AmazonClientManager ddb] updateItem:request];
- }
- @catch (NSException *exception)
- {
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ DynamoDBAttributeValue *attr = [[[DynamoDBAttributeValue alloc] initWithS:aValue] autorelease];
+ DynamoDBAttributeValueUpdate *attrUpdate = [[[DynamoDBAttributeValueUpdate alloc] initWithValue:attr andAction:@"PUT"] autorelease];
+
+ DynamoDBUpdateItemRequest *request = [[[DynamoDBUpdateItemRequest alloc] initWithTableName:TEST_TABLE_NAME
+ andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:aPrimaryKey] autorelease]
+ andAttributeUpdates:[NSMutableDictionary dictionaryWithObject:attrUpdate forKey:aKey]] autorelease];
+ DynamoDBUpdateItemResponse *response = [[AmazonClientManager ddb] updateItem:request];
+ if(response.error != nil)
+ {
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
}
}
@@ -170,16 +160,13 @@ +(void)updateAttributeStringValue:(NSString *)aValue forKey:(NSString *)aKey wit
*/
+(void)deleteUser:(DynamoDBAttributeValue *)aPrimaryKey
{
- @try
- {
- DynamoDBDeleteItemRequest *request = [[[DynamoDBDeleteItemRequest alloc] initWithTableName:TEST_TABLE_NAME andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:aPrimaryKey] autorelease]] autorelease];
-
- [[AmazonClientManager ddb] deleteItem:request];
- }
- @catch (NSException *exception)
+ DynamoDBDeleteItemRequest *request = [[[DynamoDBDeleteItemRequest alloc] initWithTableName:TEST_TABLE_NAME andKey:[[[DynamoDBKey alloc] initWithHashKeyElement:aPrimaryKey] autorelease]] autorelease];
+
+ DynamoDBDeleteItemResponse *response = [[AmazonClientManager ddb] deleteItem:request];
+ if(response.error != nil)
{
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
}
}
@@ -188,15 +175,12 @@ +(void)deleteUser:(DynamoDBAttributeValue *)aPrimaryKey
*/
+(void)cleanUp
{
- @try
- {
- DynamoDBDeleteTableRequest *request = [[[DynamoDBDeleteTableRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
- [[AmazonClientManager ddb] deleteTable:request];
- }
- @catch (NSException *exception)
+ DynamoDBDeleteTableRequest *request = [[[DynamoDBDeleteTableRequest alloc] initWithTableName:TEST_TABLE_NAME] autorelease];
+ DynamoDBDeleteTableResponse *response = [[AmazonClientManager ddb] deleteTable:request];
+ if(response.error != nil)
{
- [AmazonClientManager wipeCredentialsOnAuthError:exception];
- NSLog(@"Exception: %@", exception);
+ [AmazonClientManager wipeCredentialsOnAuthError:response.error];
+ NSLog(@"Error: %@", response.error);
}
}
View
17 samples/DynamoDB_UserPreference/UserPreference/UserPreference-Prefix.pch
@@ -1,6 +1,17 @@
-//
-// Prefix header for all source files of the 'UserPreference' target in the 'UserPreference' project
-//
+/*
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
#import <Availability.h>
#import "Constants.h"
View
2 samples/DynamoDB_UserPreference/UserPreference/WelcomeViewController.m
@@ -130,7 +130,7 @@ -(void)showAlert:(NSString *)message withStatus:(NSString *)status
initWithTitle:@"Warning"
message:[NSString stringWithFormat:@"%@\nTable Status: %@.",
message,
- status]
+ status == nil ? @"table does not exist" : status]
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
View
31 samples/DynamoDB_UserPreference/UserPreference/main.m
@@ -1,25 +1,26 @@
-//
-// main.m
-// UserPreference
-//
-// Created by Matsuda, Yosuke on 12/23/11.
-// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
-//
+/*
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
- @try
+ @autoreleasepool
{
- @autoreleasepool
- {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
- }
- }
- @catch (NSException *exception) {
- NSLog(@"Exception: %@", exception);
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
View
4 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoAppDelegate.m
@@ -16,7 +16,7 @@
#import "AWSiOSDemoAppDelegate.h"
#import "AWSiOSDemoViewController.h"
#import <AWSiOSSDK/AmazonLogger.h>
-
+#import <AWSiOSSDK/AmazonErrorHandler.h>
@implementation AWSiOSDemoAppDelegate
@@ -35,6 +35,8 @@ -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(N
[AmazonLogger turnLoggingOff];
#endif
+ [AmazonErrorHandler shouldNotThrowExceptions];
+
return YES;
}
View
14 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddBucketViewController.m
@@ -23,14 +23,14 @@ @implementation AddBucketViewController
-(IBAction)add:(id)sender
{
[bucketName resignFirstResponder];
-
- @try {
- [[AmazonClientManager s3] createBucket:[[[S3CreateBucketRequest alloc] initWithName:bucketName.text] autorelease]];
- }
- @catch (AmazonClientException *exception) {
- NSLog(@"Failed to Creater Bucket [%@]", exception);
+
+ S3CreateBucketRequest *request = [[[S3CreateBucketRequest alloc] initWithName:bucketName.text] autorelease];
+ S3CreateBucketResponse *response = [[AmazonClientManager s3] createBucket:request];
+ if(response.error != nil)
+ {
+ NSLog(@"Error: %@", response.error);
}
-
+
[self dismissModalViewControllerAnimated:YES];
}
View
20 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddObjectViewController.m
@@ -25,18 +25,18 @@ -(IBAction)add:(id)sender
{
[objectName resignFirstResponder];
[objectData resignFirstResponder];
-
+
NSData *data = [objectData.text dataUsingEncoding:NSUTF8StringEncoding];
- @try {
- S3PutObjectRequest *por = [[[S3PutObjectRequest alloc] initWithKey:objectName.text inBucket:self.bucket] autorelease];
- por.data = data;
-
- [[AmazonClientManager s3] putObject:por];
+
+ S3PutObjectRequest *request = [[[S3PutObjectRequest alloc] initWithKey:objectName.text inBucket:self.bucket] autorelease];
+ request.data = data;
+
+ S3PutObjectResponse *response = [[AmazonClientManager s3] putObject:request];
+ if(response.error != nil)
+ {
+ NSLog(@"Error: %@", response.error);
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Failed to Create Object [%@]", exception);
- }
-
+
[self dismissModalViewControllerAnimated:YES];
}
View
37 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageUploader.m
@@ -27,18 +27,18 @@ -(id)initWithImageNo:(int)theImageNo progressView:(UIProgressView *)theProgressV
{
imageNo = theImageNo;
progressView = [theProgressView retain];
-
+
isExecuting = NO;
isFinished = NO;
}
-
+
return self;
}
-(void)dealloc
{
[progressView release];
-
+
[super dealloc];
}
@@ -60,32 +60,29 @@ -(void)start
[self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO];
return;
}
-
+
[self willChangeValueForKey:@"isExecuting"];
isExecuting = YES;
[self didChangeValueForKey:@"isExecuting"];
-
+
[self performSelectorOnMainThread:@selector(initializeProgressView) withObject:nil waitUntilDone:NO];
-
+
NSString *bucketName = [NSString stringWithFormat:@"s3-async-demo2-ios-for-%@", [ACCESS_KEY_ID lowercaseString]];
NSString *keyName = [NSString stringWithFormat:@"image%d", imageNo];
NSString *filename = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"image%d", imageNo] ofType:@"png"];
-
+
// Creates the Bucket to put the Object.
- @try
- {
- [[AmazonClientManager s3] createBucketWithName:bucketName];
- }
- @catch (NSException *e)
+ S3CreateBucketResponse *createBucketResponse = [[AmazonClientManager s3] createBucketWithName:bucketName];
+ if(createBucketResponse.error != nil)
{
- NSLog(@"%@", e);
+ NSLog(@"Error: %@", createBucketResponse.error);
}
-
+
// Puts the file as an object in the bucket.
S3PutObjectRequest *putObjectRequest = [[[S3PutObjectRequest alloc] initWithKey:keyName inBucket:bucketName] autorelease];
putObjectRequest.filename = filename;
putObjectRequest.delegate = self;
-
+
[[AmazonClientManager s3] putObject:putObjectRequest];
}
@@ -109,7 +106,7 @@ -(BOOL)isFinished
-(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response
{
[self performSelectorOnMainThread:@selector(hideProgressView) withObject:nil waitUntilDone:NO];
-
+
[self finish];
}
@@ -121,14 +118,14 @@ -(void)request:(AmazonServiceRequest *)request didSendData:(NSInteger)bytesWritt
-(void)request:(AmazonServiceRequest *)request didFailWithError:(NSError *)error
{
NSLog(@"%@", error);
-
+
[self finish];
}
-(void)request:(AmazonServiceRequest *)request didFailWithServiceException:(NSException *)exception
{
NSLog(@"%@", exception);
-
+
[self finish];
}
@@ -138,10 +135,10 @@ -(void)finish
{
[self willChangeValueForKey:@"isExecuting"];
[self willChangeValueForKey:@"isFinished"];
-
+
isExecuting = NO;
isFinished = YES;
-
+
[self didChangeValueForKey:@"isExecuting"];
[self didChangeValueForKey:@"isFinished"];
}
View
77 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/BucketList.m
@@ -28,27 +28,22 @@ -(id)init
-(void)viewWillAppear:(BOOL)animated
{
- @try {
- NSArray *bucketNames = [[AmazonClientManager s3] listBuckets];
- if (buckets == nil) {
- buckets = [[NSMutableArray alloc] initWithCapacity:[bucketNames count]];
- }
- else {
- [buckets removeAllObjects];
- }
-
- if (bucketNames != nil) {
- for (S3Bucket *bucket in bucketNames) {
- [buckets addObject:[bucket name]];
- }
- }
-
- [buckets sortUsingSelector:@selector(compare:)];
+ NSArray *bucketNames = [[AmazonClientManager s3] listBuckets];
+ if (buckets == nil) {
+ buckets = [[NSMutableArray alloc] initWithCapacity:[bucketNames count]];
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+ else {
+ [buckets removeAllObjects];
}
-
+
+ if (bucketNames != nil) {
+ for (S3Bucket *bucket in bucketNames) {
+ [buckets addObject:[bucket name]];
+ }
+ }
+
+ [buckets sortUsingSelector:@selector(compare:)];
+
[bucketTableView reloadData];
}
@@ -60,9 +55,9 @@ -(IBAction)done:(id)sender
-(IBAction)add:(id)sender
{
AddBucketViewController *addBucketViewController = [[AddBucketViewController alloc] init];
-
+
addBucketViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
-
+
[self presentModalViewController:addBucketViewController animated:YES];
[addBucketViewController release];
}
@@ -80,48 +75,48 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
+
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
// Configure the cell...
cell.textLabel.text = [buckets objectAtIndex:indexPath.row];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
+
return cell;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
- @try {
- S3DeleteBucketRequest *deleteBucketRequest = [[[S3DeleteBucketRequest alloc] initWithName:[buckets objectAtIndex:indexPath.row]] autorelease];
- [[AmazonClientManager s3] deleteBucket:deleteBucketRequest];
-
- [buckets removeObjectAtIndex:indexPath.row];
-
- NSArray *indexPaths = [NSArray arrayWithObjects:indexPath, nil];
-
- [tableView beginUpdates];
- [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
- [tableView endUpdates];
- }
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+
+ S3DeleteBucketRequest *deleteBucketRequest = [[[S3DeleteBucketRequest alloc] initWithName:[buckets objectAtIndex:indexPath.row]] autorelease];
+ S3DeleteBucketResponse *deleteBucketResponse = [[AmazonClientManager s3] deleteBucket:deleteBucketRequest];
+ if(deleteBucketResponse.error != nil)
+ {
+ NSLog(@"Error: %@", deleteBucketResponse.error);
}
+
+ [buckets removeObjectAtIndex:indexPath.row];
+
+ NSArray *indexPaths = [NSArray arrayWithObjects:indexPath, nil];
+
+ [tableView beginUpdates];
+ [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
+ [tableView endUpdates];
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ObjectListing *objectList = [[ObjectListing alloc] init];
-
+
objectList.bucket = [buckets objectAtIndex:indexPath.row];
objectList.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
-
+
[self presentModalViewController:objectList animated:YES];
[objectList release];
}
View
100 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectListing.m
@@ -29,13 +29,17 @@ -(id)init
-(void)viewWillAppear:(BOOL)animated
{
- @try {
- S3ListObjectsRequest *listObjectRequest = [[[S3ListObjectsRequest alloc] initWithName:self.bucket] autorelease];
-
- S3ListObjectsResponse *listObjectResponse = [[AmazonClientManager s3] listObjects:listObjectRequest];
- S3ListObjectsResult *listObjectsResults = listObjectResponse.listObjectsResult;
-
-
+ S3ListObjectsRequest *listObjectRequest = [[[S3ListObjectsRequest alloc] initWithName:self.bucket] autorelease];
+ S3ListObjectsResponse *listObjectResponse = [[AmazonClientManager s3] listObjects:listObjectRequest];
+ if(listObjectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", listObjectResponse.error);
+ [objects addObject:@"Unable to load objects!"];
+ }
+ else
+ {
+ S3ListObjectsResult *listObjectsResults = listObjectResponse.listObjectsResult;
+
if (objects == nil) {
objects = [[NSMutableArray alloc] initWithCapacity:[listObjectsResults.objectSummaries count]];
}
@@ -57,6 +61,14 @@ -(void)viewWillAppear:(BOOL)animated
listObjectRequest.marker = lastKey;
listObjectResponse = [[AmazonClientManager s3] listObjects:listObjectRequest];
+ if(listObjectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", listObjectResponse.error);
+ [objects addObject:@"Unable to load objects!"];
+
+ break;
+ }
+
listObjectsResults = listObjectResponse.listObjectsResult;
for (S3ObjectSummary *objectSummary in listObjectsResults.objectSummaries) {
@@ -65,11 +77,7 @@ -(void)viewWillAppear:(BOOL)animated
}
}
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
- [objects addObject:@"Unable to load objects!"];
- }
-
+
[objectsTableView reloadData];
}
@@ -81,10 +89,10 @@ -(IBAction)done:(id)sender
-(IBAction)add:(id)sender
{
AddObjectViewController *addObject = [[AddObjectViewController alloc] init];
-
+
addObject.bucket = self.bucket;
addObject.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
-
+
[self presentModalViewController:addObject animated:YES];
[addObject release];
}
@@ -103,17 +111,17 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
+
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
// Configure the cell...
cell.textLabel.text = [objects objectAtIndex:indexPath.row];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
+
return cell;
}
@@ -125,42 +133,36 @@ -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)i
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- @try {
- ObjectViewController *objectView = [[ObjectViewController alloc] init];
- objectView.bucket = self.bucket;
- objectView.objectName = [objects objectAtIndex:indexPath.row];
- objectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
-
- [self presentModalViewController:objectView animated:YES];
- [objectView release];
- }
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
- }
+ ObjectViewController *objectView = [[ObjectViewController alloc] init];
+ objectView.bucket = self.bucket;
+ objectView.objectName = [objects objectAtIndex:indexPath.row];
+ objectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
+
+ [self presentModalViewController:objectView animated:YES];
+ [objectView release];
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- @try {
- S3DeleteObjectRequest *dor = [[[S3DeleteObjectRequest alloc] init] autorelease];
- dor.bucket = self.bucket;
- dor.key = [objects objectAtIndex:indexPath.row];
-
- [[AmazonClientManager s3] deleteObject:dor];
- [objects removeObjectAtIndex:indexPath.row];
-
- NSArray *indexPaths = [NSArray arrayWithObjects:indexPath, nil];
-
- [tableView beginUpdates];
- [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
- [tableView endUpdates];
- }
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+ if (editingStyle == UITableViewCellEditingStyleDelete)
+ {
+ S3DeleteObjectRequest *dor = [[[S3DeleteObjectRequest alloc] init] autorelease];
+ dor.bucket = self.bucket;
+ dor.key = [objects objectAtIndex:indexPath.row];
+
+ S3DeleteObjectResponse *deleteObjectResponse = [[AmazonClientManager s3] deleteObject:dor];
+ if(deleteObjectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", deleteObjectResponse.error);
}
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
+
+ [objects removeObjectAtIndex:indexPath.row];
+
+ NSArray *indexPaths = [NSArray arrayWithObjects:indexPath, nil];
+
+ [tableView beginUpdates];
+ [tableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
+ [tableView endUpdates];
}
}
View
17 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectViewController.m
@@ -33,16 +33,15 @@ -(IBAction)done:(id)sender
-(void)viewWillAppear:(BOOL)animated
{
- @try {
- S3GetObjectRequest *getObjectRequest = [[[S3GetObjectRequest alloc] initWithKey:self.objectName withBucket:self.bucket] autorelease];
- S3GetObjectResponse *getObjectResponse = [[AmazonClientManager s3] getObject:getObjectRequest];
-
- self.objectNameLabel.text = self.objectName;
- self.objectDataLabel.text = [[NSString alloc] initWithData:getObjectResponse.body encoding:NSUTF8StringEncoding];
- }
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+ S3GetObjectRequest *getObjectRequest = [[[S3GetObjectRequest alloc] initWithKey:self.objectName withBucket:self.bucket] autorelease];
+ S3GetObjectResponse *getObjectResponse = [[AmazonClientManager s3] getObject:getObjectRequest];
+ if(getObjectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", getObjectResponse.error);
}
+
+ self.objectNameLabel.text = self.objectName;
+ self.objectDataLabel.text = [[NSString alloc] initWithData:getObjectResponse.body encoding:NSUTF8StringEncoding];
}
-(void)dealloc
View
33 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3AsyncViewController.m
@@ -29,7 +29,7 @@ -(id)init
s3ResponseHandler = [[S3ResponseHandler alloc] init];
putObjectRequest = nil;
getObjectRequest = nil;
-
+
return [super initWithNibName:@"S3AsyncViewController" bundle:nil];
}
@@ -43,7 +43,7 @@ -(IBAction)start:(id)sender
{
bytesIn.text = @"0";
bytesOut.text = @"0";
-
+
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(putObject) userInfo:nil repeats:NO];
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(getObject) userInfo:nil repeats:NO];
}
@@ -53,7 +53,7 @@ -(IBAction)stop:(id)sender
if (putObjectRequest != nil) {
[putObjectRequest.urlConnection cancel];
}
-
+
if (getObjectRequest != nil) {
[getObjectRequest.urlConnection cancel];
}
@@ -69,35 +69,36 @@ -(void)putObject
NSString *bucketName = [NSString stringWithFormat:@"testing-async-with-s3-for%@", [ACCESS_KEY_ID lowercaseString]];
NSString *keyName = @"asyncTestFile";
NSString *filename = [[NSBundle mainBundle] pathForResource:@"temp" ofType:@"txt"];
-
+
// Create the Bucket to put the Object.
- @try
+ S3CreateBucketResponse *createBucketResponse = [[AmazonClientManager s3] createBucketWithName:bucketName];
+ if(createBucketResponse.error != nil)
{
- [[AmazonClientManager s3] createBucketWithName:bucketName];
- }
- @catch (NSException *e) {
- NSLog(@"%@", e);
- return;
+ NSLog(@"Error: %@", createBucketResponse.error);
}
-
+
// Put the file as an object in the bucket.
- putObjectRequest = [[S3PutObjectRequest alloc] initWithKey:keyName inBucket:bucketName];
+ putObjectRequest = [[S3PutObjectRequest alloc] initWithKey:keyName inBucket:bucketName];
putObjectRequest.filename = filename;
[putObjectRequest setDelegate:s3ResponseHandler];
-
+
// When using delegates the return is nil.
- [[AmazonClientManager s3] putObject:putObjectRequest];
+ S3PutObjectResponse *putObjectResponse = [[AmazonClientManager s3] putObject:putObjectRequest];
+ if(putObjectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", putObjectResponse.error);
+ }
}
-(void)getObject
{
NSString *bucketName = [NSString stringWithFormat:@"testing-async-with-s3-for%@", [ACCESS_KEY_ID lowercaseString]];
NSString *keyName = @"asyncTestFile";
-
+
// Get the object from the bucket.
getObjectRequest = [[S3GetObjectRequest alloc] initWithKey:keyName withBucket:bucketName];
[getObjectRequest setDelegate:s3ResponseHandler];
-
+
// When using delegates the return is nil.
[[AmazonClientManager s3] getObject:getObjectRequest];
}
View
70 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3NSOperationDemoViewController.m
@@ -43,14 +43,14 @@ -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceO
-(IBAction)uploadImages:(id)sender
{
AsyncImageUploader *imageUploader1 = [[AsyncImageUploader alloc] initWithImageNo:1 progressView:uploadProgress1];
-
+
[operationQueue addOperation:imageUploader1];
[imageUploader1 release];
-
+
AsyncImageUploader *imageUploader2 = [[AsyncImageUploader alloc] initWithImageNo:2 progressView:uploadProgress2];
[operationQueue addOperation:imageUploader2];
[imageUploader2 release];
-
+
AsyncImageUploader *imageUploader3 = [[AsyncImageUploader alloc] initWithImageNo:3 progressView:uploadProgress3];
[operationQueue addOperation:imageUploader3];
[imageUploader3 release];
@@ -59,14 +59,14 @@ -(IBAction)uploadImages:(id)sender
-(IBAction)downloadImages:(id)sender
{
AsyncImageDownloader *imageDownloader1 = [[AsyncImageDownloader alloc] initWithImageNo:1 progressView:downloadProgress1 imageview:downloadImage1];
-
+
[operationQueue addOperation:imageDownloader1];
[imageDownloader1 release];
-
+
AsyncImageDownloader *imageDownloader2 = [[AsyncImageDownloader alloc] initWithImageNo:2 progressView:downloadProgress2 imageview:downloadImage2];
[operationQueue addOperation:imageDownloader2];
[imageDownloader2 release];
-
+
AsyncImageDownloader *imageDownloader3 = [[AsyncImageDownloader alloc] initWithImageNo:3 progressView:downloadProgress3 imageview:downloadImage3];
[operationQueue addOperation:imageDownloader3];
[imageDownloader3 release];
@@ -75,48 +75,54 @@ -(IBAction)downloadImages:(id)sender
-(IBAction)done:(id)sender
{
[self retain];
-
+
NSInvocationOperation *io = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(deleteBucket) object:nil];
[operationQueue addOperation:io];
[io release];
-
+
[self dismissModalViewControllerAnimated:YES];
}
#pragma mark - Helper Methods
-(void)deleteBucket
{
- @try
+ // Gets all of the objects in the test bucket.
+ NSString *bucketName = [NSString stringWithFormat:@"s3-async-demo2-ios-for-%@", [ACCESS_KEY_ID lowercaseString]];
+ S3ListObjectsRequest *listRequest = [[S3ListObjectsRequest alloc] initWithName:bucketName];
+ S3ListObjectsResponse *listResponse = [[AmazonClientManager s3] listObjects:listRequest];
+ if(listResponse.error != nil)
{
- // Gets all of the objects in the test bucket.
- NSString *bucketName = [NSString stringWithFormat:@"s3-async-demo2-ios-for-%@", [ACCESS_KEY_ID lowercaseString]];
- S3ListObjectsRequest *listRequest = [[S3ListObjectsRequest alloc] initWithName:bucketName];
- S3ListObjectsResponse *listResponse = [[AmazonClientManager s3] listObjects:listRequest];
-
- // Deletes each object in the test bucket.
- S3DeleteObjectRequest *deleteRequest = nil;
- for (S3ObjectSummary *os in listResponse.listObjectsResult.objectSummaries)
+ NSLog(@"Error: %@", listResponse.error);
+ }
+
+ // Deletes each object in the test bucket.
+ S3DeleteObjectRequest *deleteRequest = nil;
+ for (S3ObjectSummary *os in listResponse.listObjectsResult.objectSummaries)
+ {
+ deleteRequest = [S3DeleteObjectRequest new];
+ deleteRequest.bucket = bucketName;
+ deleteRequest.key = os.key;
+
+ S3DeleteObjectResponse *deleteObjectResponse = [[AmazonClientManager s3] deleteObject:deleteRequest];
+ if(deleteObjectResponse.error != nil)
{
- deleteRequest = [S3DeleteObjectRequest new];
- deleteRequest.bucket = bucketName;
- deleteRequest.key = os.key;
-
- [[AmazonClientManager s3] deleteObject:deleteRequest];
-
- [deleteRequest release];
+ NSLog(@"Error: %@", deleteObjectResponse.error);
}
-
- // Deletes the test bucket. The bucket must be empty in order to be deleted.
- S3DeleteBucketRequest *deleteBucketReqeust = [[S3DeleteBucketRequest alloc] initWithName:bucketName];
- [[AmazonClientManager s3] deleteBucket:deleteBucketReqeust];
- [deleteBucketReqeust release];
+
+ [deleteRequest release];
}
- @catch (NSException *ex)
+
+ // Deletes the test bucket. The bucket must be empty in order to be deleted.
+ S3DeleteBucketRequest *deleteBucketReqeust = [[S3DeleteBucketRequest alloc] initWithName:bucketName];
+ S3DeleteBucketResponse *deleteBucketResponse = [[AmazonClientManager s3] deleteBucket:deleteBucketReqeust];
+ if(deleteBucketResponse.error != nil)
{
- NSLog(@"%@", ex);
+ NSLog(@"Error: %@", deleteBucketResponse.error);
}
-
+
+ [deleteBucketReqeust release];
+
[self release];
}
View
44 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/DomainList.m
@@ -26,26 +26,24 @@ -(id)init
-(void)viewWillAppear:(BOOL)animated
{
- @try {
- SimpleDBListDomainsRequest *listDomainsRequest = [[[SimpleDBListDomainsRequest alloc] init] autorelease];
- SimpleDBListDomainsResponse *listDomainsResponse = [[AmazonClientManager sdb] listDomains:listDomainsRequest];
-
- if (domains == nil) {
- domains = [[NSMutableArray alloc] initWithCapacity:[listDomainsResponse.domainNames count]];
- }
- else {
- [domains removeAllObjects];
- }
- for (NSString *name in listDomainsResponse.domainNames) {
- [domains addObject:name];
- }
-
- [domains sortUsingSelector:@selector(compare:)];
+ SimpleDBListDomainsRequest *listDomainsRequest = [[[SimpleDBListDomainsRequest alloc] init] autorelease];
+ SimpleDBListDomainsResponse *listDomainsResponse = [[AmazonClientManager sdb] listDomains:listDomainsRequest];
+ if(listDomainsResponse.error != nil)
+ {
+ NSLog(@"Error: %@", listDomainsResponse.error);
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+
+ if (domains == nil) {
+ domains = [[NSMutableArray alloc] initWithCapacity:[listDomainsResponse.domainNames count]];
}
-
+ else {
+ [domains removeAllObjects];
+ }
+ for (NSString *name in listDomainsResponse.domainNames) {
+ [domains addObject:name];
+ }
+
+ [domains sortUsingSelector:@selector(compare:)];
[domainTableView reloadData];
}
@@ -67,24 +65,24 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
+
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
// Configure the cell...
cell.textLabel.text = [domains objectAtIndex:indexPath.row];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
+
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ItemListing *itemList = [[ItemListing alloc] init];
-
+
itemList.domain = [domains objectAtIndex:indexPath.row];
itemList.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:itemList animated:YES];
View
46 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemListing.m
@@ -30,26 +30,26 @@ -(id)init
-(void)viewWillAppear:(BOOL)animated
{
NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@`", self.domain];
-
- @try {
- SimpleDBSelectRequest *selectRequest = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
- SimpleDBSelectResponse *selectResponse = [[AmazonClientManager sdb] select:selectRequest];
-
- if (items == nil) {
- items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
- }
- else {
- [items removeAllObjects];
- }
- for (SimpleDBItem *item in selectResponse.items) {
- [items addObject:item.name];
- }
- [items sortUsingSelector:@selector(compare:)];
+
+ SimpleDBSelectRequest *selectRequest = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
+ SimpleDBSelectResponse *selectResponse = [[AmazonClientManager sdb] select:selectRequest];
+ if(selectResponse.error != nil)
+ {
+ NSLog(@"Error: %@", selectResponse.error);
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+
+ if (items == nil) {
+ items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
}
-
+ else {
+ [items removeAllObjects];
+ }
+
+ for (SimpleDBItem *item in selectResponse.items) {
+ [items addObject:item.name];
+ }
+
+ [items sortUsingSelector:@selector(compare:)];
[itemsTableView reloadData];
}
@@ -71,16 +71,16 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
+
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
cell.textLabel.text = [items objectAtIndex:indexPath.row];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
+
return cell;
}
@@ -92,7 +92,7 @@ -(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)i
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ItemViewController *itemView = [[ItemViewController alloc] init];
-
+
itemView.domain = self.domain;
itemView.itemName = [items objectAtIndex:indexPath.row];
itemView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
View
42 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemViewController.m
@@ -33,25 +33,25 @@ -(IBAction)done:(id)sender
-(void)viewWillAppear:(BOOL)animated
{
- @try {
- SimpleDBGetAttributesRequest *gar = [[[SimpleDBGetAttributesRequest alloc] initWithDomainName:self.domain andItemName:self.itemName] autorelease];
- SimpleDBGetAttributesResponse *response = [[AmazonClientManager sdb] getAttributes:gar];
-
- if (data == nil) {
- data = [[NSMutableArray alloc] initWithCapacity:[response.attributes count]];
- }
- else {
- [data removeAllObjects];
- }
- for (SimpleDBAttribute *attr in response.attributes) {
- [data addObject:[NSString stringWithFormat:@"%@ => %@", attr.name, attr.value]];
- }
- [data sortUsingSelector:@selector(compare:)];
+ SimpleDBGetAttributesRequest *gar = [[[SimpleDBGetAttributesRequest alloc] initWithDomainName:self.domain andItemName:self.itemName] autorelease];
+ SimpleDBGetAttributesResponse *response = [[AmazonClientManager sdb] getAttributes:gar];
+ if(response.error != nil)
+ {
+ NSLog(@"Error: %@", response.error);
}
- @catch (AmazonClientException *exception) {
- NSLog(@"Exception = %@", exception);
+
+ if (data == nil) {
+ data = [[NSMutableArray alloc] initWithCapacity:[response.attributes count]];
}
-
+ else {
+ [data removeAllObjects];
+ }
+
+ for (SimpleDBAttribute *attr in response.attributes) {
+ [data addObject:[NSString stringWithFormat:@"%@ => %@", attr.name, attr.value]];
+ }
+
+ [data sortUsingSelector:@selector(compare:)];
[dataTableView reloadData];
}
@@ -68,16 +68,16 @@ -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
+
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
cell.textLabel.text = [data objectAtIndex:indexPath.row];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
-
+
return cell;
}
View
90 samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbAsyncViewController.m
@@ -33,7 +33,7 @@ -(id)init
domainName = @"testing-async-with-sdb";
selectRequest = nil;
putAttributesRequest = nil;
-
+
return [super initWithNibName:@"SdbAsyncViewController" bundle:nil];
}
@@ -47,12 +47,12 @@ -(IBAction)start:(id)sender
{
bytesIn.text = @"0";
bytesOut.text = @"0";
-
+
if (timer != nil && [timer isValid]) {
[timer invalidate];
timer = nil;
}
-
+
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(perform) userInfo:nil repeats:YES];
counter = 0;
}
@@ -63,13 +63,13 @@ -(IBAction)stop:(id)sender
[timer invalidate];
timer = nil;
}
-
+
counter = 0;
-
+
if (selectRequest != nil) {
[selectRequest.urlConnection cancel];
}
-
+
if (putAttributesRequest != nil) {
[putAttributesRequest.urlConnection cancel];
}
@@ -81,7 +81,7 @@ -(IBAction)exit:(id)sender
[timer invalidate];
timer = nil;
}
-
+
counter = 0;
[self dismissModalViewControllerAnimated:YES];
}
@@ -97,62 +97,61 @@ -(void)perform
if (counter == 0) {
[self createDomain];
}
-
+
[self putAttributes];
[self selectAttributes];
-
+
counter++;
}
}
-(void)createDomain
{
- @try {
- SimpleDBCreateDomainRequest *createDomainRequest = [[[SimpleDBCreateDomainRequest alloc] initWithDomainName:domainName] autorelease];
- [createDomainRequest setDelegate:sdbDelegate];
- [[AmazonClientManager sdb] createDomain:createDomainRequest];
- }
- @catch (NSException *exception) {
- NSLog(@"%@", exception);
+ SimpleDBCreateDomainRequest *createDomainRequest = [[[SimpleDBCreateDomainRequest alloc] initWithDomainName:domainName] autorelease];
+ [createDomainRequest setDelegate:sdbDelegate];
+ SimpleDBCreateDomainResponse *createDomainResponse = [[AmazonClientManager sdb] createDomain:createDomainRequest];
+ if(createDomainResponse.error != nil)
+ {
+ NSLog(@"Error: %@", createDomainResponse.error);
}
}
-(void)putAttributes
{
- @try {
- NSMutableArray *attributes = [[[NSMutableArray alloc] initWithCapacity:200] autorelease];
- for (int i = 0; i < 200; i++) {
- NSString *att = [NSString stringWithFormat:@"attribute-%d", i];
- NSString *val = [NSString stringWithFormat:@"value-%d", i];
- SimpleDBReplaceableAttribute *replacableAttribute = [[[SimpleDBReplaceableAttribute alloc] initWithName:att andValue:val andReplace:YES] autorelease];
- [attributes addObject:replacableAttribute];
- }
- for (int i = 0; i < 10; i++) {
- NSString *itemName = [NSString stringWithFormat:@"Item-%d", i];
-
- putAttributesRequest = [[SimpleDBPutAttributesRequest alloc] initWithDomainName:domainName andItemName:itemName andAttributes:attributes];
- [putAttributesRequest setDelegate:sdbDelegate];
-
- [[AmazonClientManager sdb] putAttributes:putAttributesRequest];
- }
+ NSMutableArray *attributes = [[[NSMutableArray alloc] initWithCapacity:200] autorelease];
+
+ for (int i = 0; i < 200; i++) {
+ NSString *att = [NSString stringWithFormat:@"attribute-%d", i];
+ NSString *val = [NSString stringWithFormat:@"value-%d", i];
+ SimpleDBReplaceableAttribute *replacableAttribute = [[[SimpleDBReplaceableAttribute alloc] initWithName:att andValue:val andReplace:YES] autorelease];
+ [attributes addObject:replacableAttribute];
}
- @catch (NSException *exception) {
- NSLog(@"%@", exception);
+
+ for (int i = 0; i < 10; i++) {
+ NSString *itemName = [NSString stringWithFormat:@"Item-%d", i];
+
+ putAttributesRequest = [[SimpleDBPutAttributesRequest alloc] initWithDomainName:domainName andItemName:itemName andAttributes:attributes];
+ [putAttributesRequest setDelegate:sdbDelegate];
+
+ SimpleDBPutAttributesResponse *putAttributesResponse = [[AmazonClientManager sdb] putAttributes:putAttributesRequest];
+ if(putAttributesResponse.error != nil)
+ {
+ NSLog(@"Error: %@", putAttributesResponse.error);
+ }
}
}
-(void)selectAttributes
{
- @try {
- NSString *selectExpression = [NSString stringWithFormat:@"select * from `%@`", domainName];
- selectRequest = [[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression];
- [selectRequest setDelegate:sdbDelegate];
- selectRequest.consistentRead = YES;
-
- [[AmazonClientManager sdb] select:selectRequest];
- }
- @catch (NSException *exception) {
- NSLog(@"%@", exception);
+