我从我的AWS服务器上拉取歌曲名称数组。NSString作为参数失败,但文字字符串的作品?
我的下一步是使用这些歌曲名称之一作为检索其流传输URL的请求中的参数。
//[1] Initialize the S3 Client.
self.s3 = [[AmazonS3Client alloc] initWithAccessKey:@"blah" withSecretKey:@"blah"];
self.s3.endpoint = [AmazonEndpoints s3Endpoint:US_WEST_2];
//[2] Get an array of song names
NSArray *song_array = [self.s3 listObjectsInBucket:@"blahblah"];
NSLog(@"the objects are %@", song_array);
//[3] Get a single song name from the array
NSString *song1 = [[NSString alloc] init];
song1 = (NSString *)[song_array objectAtIndex:1];
NSLog(@"%@", song1);
NSString * song2 = @"Rap God.mp3";
NSLog(@"%@", song2);
//[4] Get the Song URL
S3GetPreSignedURLRequest *gpsur = [[S3GetPreSignedURLRequest alloc] init];
gpsur.key = song2;
gpsur.bucket [email protected]"soundshark";
gpsur.expires = [NSDate dateWithTimeIntervalSinceNow:(NSTimeInterval) 3600];
NSError *error;
NSURL *url = [self.s3 getPreSignedURL:gpsur error:&error];
NSLog(@"the url is %@", url);
Song2完美地作为参数gpsur.key。
然而,如果我使用松1作为参数,它失败,错误
终止应用程序由于未捕获的异常“NSInvalidArgumentException”,原因:“ - [S3ObjectSummary stringWithURLEncoding]:无法识别的选择发送到实例0x175aef30
当我使用的NSLog,既松1和song2打印完全相同的字符串“说唱God.mp3”
为什么出错?为什么我不能使用数组中的字符串?它具有完全相同的价值?
我爱你...... – user1161310