0
-(void)getWord:(NSString*)upperCaseString :(NSString *)combinedString :(NSString *)wordIndex
{
    NSURL *url = [NSURL URLWithString:@"http://quicklanguages.com/materiales/quicklanguages/audios/%@/%@-%@.mp3",@"upperCaseString", @"combinedString", @"wordIndex" ];
    //  [tweetSheet setInitialText:[NSString stringWithFormat:@"%@", 
    [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:nil]; 
    // Now we are assigning it in an instance variable thus ARC will not deallocate it.
    [audioPlayer play];
}

I make a method and passing three arguments , Now can can set these arguments with this URL .....

thxou
  • 691
  • 7
  • 20
  • Please update your question with the code as text in addition to the picture. – rmaddy Jun 13 '18 at 06:46
  • -(void)getWord:(NSString*)upperCaseString :(NSString *)combinedString :(NSString *)wordIndex { NSURL *url = [NSURL URLWithString:@"http://quicklanguages.com/materiales/quicklanguages/audios/%@/%@-%@.mp3",@"upperCaseString", @"combinedString", @"wordIndex" ];} –  Jun 13 '18 at 06:48
  • 2
    Don't post code in comments. Update your question. – rmaddy Jun 13 '18 at 06:49

1 Answers1

0

The right way to do it is this:

NSString *urlString = [NSString stringWithFormat:@"http://bla.bla/bla/%@/%@-%@.mp3", @"upperCaseString", @"combinedString", @"wordIndex"];
NSURL *url = [NSURL URLWithString:urlString];

Edit:

The final code will look like this:

-(void)getWord:(NSString*)upperCaseString :(NSString *)combinedString :(NSString *)wordIndex
{
    NSString *urlString = [NSString stringWithFormat:@"http://quicklanguages.com/materiales/quicklanguages/audios/%@/%@-%@.mp3",@"upperCaseString", @"combinedString", @"wordIndex"];
    NSURL *url = [NSURL URLWithString:urlString];
    //  [tweetSheet setInitialText:[NSString stringWithFormat:@"%@", 
    [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]]];
    NSData *data = [NSData dataWithContentsOfURL:url];
    audioPlayer = [[AVAudioPlayer alloc] initWithData:data error:nil]; 
    // Now we are assigning it in an instance variable thus ARC will not deallocate it.
    [audioPlayer play];
}
thxou
  • 691
  • 7
  • 20