【发布时间】:2013-12-27 21:45:49
【问题描述】:
基本上我想做的是将 NSString 转换为 NSIndexPath。当我使用 S3 获取对象时,我需要使用 requestTag 属性,该属性采用 NSString。我使用这个标签来确定哪个对象已经完成下载,从而确定哪个活动指示器停止旋转。下面是部分代码。如何将 NSString requestTag 转换为 NSIndexPath?
- (void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView *activityView = (UIActivityIndicatorView *)[cell viewWithTag:103];
if (![self.activityIndictatorOn containsObject:indexPath]) {
[self.activityIndictatorOn addObject:indexPath];
[activityView startAnimating];
...
getObjectRequest.requestTag = [NSString stringWithFormat:@"%@", indexPath];
}
-(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response
{
NSLog(@"DOWNLOAD COMPLETE");
[self stopActivityIndicator:request.requestTag];
[self.downloadFinished addObject:request.requestTag];
}
-(void)stopActivityIndicator:(NSString *)rowAtIndexPath
{
//Need to convert rowAtIndexPath to NSIndexPath
//Following line results in warning
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:rowAtIndexPath];
UIActivityIndicatorView *activityView = (UIActivityIndicatorView *)[cell viewWithTag:103];
[activityView stopAnimating];
}
【问题讨论】:
标签: ios objective-c amazon-web-services type-conversion nsindexpath