Golang的新手。如果我想通过索引使用forloop构造10个不同的变量(下面的示例),那么连接索引和变量名的最有效方法是什么?显然,以下方法是不正确的。
...
self.downloadDelegate = [[SessionDownloadDelegate alloc] init];
downloadDelegate.notification = notification
//Now use the downloadDelegate instead of self
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:downloadDelegate delegateQueue:nil];
...
@interface SessionDownloadDelegate: NSObject<NSURLSessionDownloadDelegate>
@property (strong, nonatomic) NSObject *notification;
@end
@implementation SessionDownloadDelegate
- (void)URLSession:(nonnull NSURLSession *)session downloadTask:(nonnull NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(nonnull NSURL *)location {
// access the notification object
// self.notification
}
@end