We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
我想把AWS dynamoDB里的data 加入到dataSource里, 在block里可以添加,可是离开了block, dataSource就是空的了。我知道是因为block在return [dataSource copy]之后在complete,请问有什么解决方法吗?谢谢
(NSArray *)newDataSource {
// __block NSMutableArray *dataSource = [[NSMutableArray alloc] init];
__block NSMutableArray *dataSource = nil; dataSource = [[NSMutableArray alloc] init];
NSDictionary *nameStyle = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:16], @"userName":[WPAttributedStyleAction styledActionWithAction:^{ [[[UIAlertView alloc] initWithTitle:@"提示" message:@"点击了" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil] show]; }], @"link": [UIColor blueColor]};
listViewItem *listItem = [[listViewItem alloc] init]; AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper]; AWSDynamoDBScanExpression *scanExpression = [AWSDynamoDBScanExpression new]; scanExpression.limit = @20; NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyy-MM-dd"]; NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init]; [timeFormat setDateFormat:@"HH:mm:00"]; NSString *currentDate = [dateFormat stringFromDate:today]; //NSString *currentTime = [timeFormat stringFromDate:today]; [[dynamoDBObjectMapper scan:[Event class] expression:scanExpression] continueWithExecutor:[AWSExecutor mainThreadExecutor] withSuccessBlock:^id(AWSTask *task) {
if (task.error) { NSLog(@"Scan Error: [%@]", task.error); }else { AWSDynamoDBPaginatedOutput *paginatedOutput = task.result; for (Event *item in paginatedOutput.items) { if ([item.StartDate isEqualToString:currentDate]) { listItem.likeCount = @"1125"; listItem.attrbutedComment = [item.Address attributedStringWithStyleBook:nameStyle]; [dataSource addObject:listItem]; NSLog(@"block dataSource array has %@",dataSource); } } NSLog(@"Scan Succeeded"); } return nil;} ];
NSLog(@"dataSource array has %@",dataSource); return [dataSource copy]; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
我想把AWS dynamoDB里的data 加入到dataSource里, 在block里可以添加,可是离开了block, dataSource就是空的了。我知道是因为block在return [dataSource copy]之后在complete,请问有什么解决方法吗?谢谢
(NSArray *)newDataSource {
// __block NSMutableArray *dataSource = [[NSMutableArray alloc] init];
__block NSMutableArray *dataSource = nil;
dataSource = [[NSMutableArray alloc] init];
NSDictionary *nameStyle = @{@"body":[UIFont fontWithName:@"HelveticaNeue" size:16],
@"userName":[WPAttributedStyleAction styledActionWithAction:^{
[[[UIAlertView alloc] initWithTitle:@"提示" message:@"点击了" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil] show];
}],
@"link": [UIColor blueColor]};
listViewItem *listItem = [[listViewItem alloc] init];
AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
AWSDynamoDBScanExpression *scanExpression = [AWSDynamoDBScanExpression new];
scanExpression.limit = @20;
NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];
[timeFormat setDateFormat:@"HH:mm:00"];
NSString *currentDate = [dateFormat stringFromDate:today];
//NSString *currentTime = [timeFormat stringFromDate:today];
[[dynamoDBObjectMapper scan:[Event class]
expression:scanExpression]
continueWithExecutor:[AWSExecutor mainThreadExecutor] withSuccessBlock:^id(AWSTask *task) {
NSLog(@"dataSource array has %@",dataSource);
return [dataSource copy];
}
The text was updated successfully, but these errors were encountered: