Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8045255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:29:24+00:00 2026-06-05T05:29:24+00:00

The example below should take a link from m3u playlist and add it to

  • 0

The example below should take a link from m3u playlist and add it to anArray. (So I will get the NSArray(NSMutableArray) with certain links in it)

NSString *fileContents = [NSString stringWithContentsOfFile:@"myfile.m3u" encoding:NSUTF8StringEncoding error:NULL];
NSArray *lines = [fileContents componentsSeparatedByString:@"\n"];
NSLog (@"%@",lines);

All the time I had (null) in NSLog Message.
All the time when I try NSLog or if/else statement to check is there is link in array it gives me the null object in it.

After that I thought the problem was in m3u type and I’ve tried to change type in txt and read. (For those who don’t know, M3U is just the text in UTF-8 encoding and the changing type should give the result)
Then I’ve tried the .txt files but it doesn’t work too. So there is the code of it.

//Check if there is my file
NSString *addPath = [[NSBundle mainBundle]  pathForResource:@"somefile" ofType:@"m3u" ];
if ([fileMgr fileExistsAtPath:addPath] ) {
    NSLog(@"Yes.We see the file");
}
else {
    NSLog(@"Nope there is no file");
}
//Rename
NSString *path1 = addPath;
NSString *theNewFilename = [path1 stringByReplacingOccurrencesOfString:@"m3u" withString:@"txt"];
NSLog(@"Renamed file adress is %@", theNewFilename); 
   
//Check if there is our renamed file(file manager was allocated before) 
NSString *addPath1 = [[NSBundle mainBundle]  pathForResource:@"somefile" ofType:@"txt" ];
if ([fileMgr fileExistsAtPath:addPath1] ) {
    NSLog(@"Yes we had the renamed file");
}
else {
    NSLog(@"No we don't");
}

Checking is there is m3u file worked fine. I had Addres to Renamed file too. But when it was checking is there is renamed file, there was no file (null in NSLog).
After all that stuff, and without any hope to reach my destination I’ve tried to read txt file line by line separated by /n with 5 links in it.

NSString *fileContents1 = [NSString stringWithContentsOfFile:@"myfile.txt" encoding:NSUTF8StringEncoding error:NULL];
NSArray *lines1 = [fileContents1 componentsSeparatedByString:@"\n"];
NSLog (@"%@",fileContents1);
NSLog (@"%@",lines1);

Both Messages were NULL
One more thing all this stuff I tried to make in -(IBAction)fileRead { } linked to button
(Yes I’ve presed button every time to check my NSLog)Program was checked in iPhone Simulator. Will be glad if someone say what is the trouble. Also if there is easier way to make this with url. (Tried Couple times with NSUrl and had Nothing but null )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:29:25+00:00Added an answer on June 5, 2026 at 5:29 am

    Just because you’ve changed the path doesn’t mean that you’ve renamed/moved/copied an item, path is just a string. Use NSFileManager methods like

    – moveItemAtURL:toURL:error: or

    – moveItemAtPath:toPath:error:.

    Also, NSString doesn’t care about extension, so it’s completely safe to read your m3u file to NSString, no need to rename it.

    NSString *addPath = [[NSBundle mainBundle]  pathForResource:@"somefile" ofType:@"m3u" ];
    if ([fileMgr fileExistsAtPath:addPath] ) {
        NSLog(@"Yes.We see the file");
        NSString *fileContents1 = [NSString stringWithContentsOfFile:addPath encoding:NSUTF8StringEncoding error:NULL];
        NSArray *lines1 = [fileContents1 componentsSeparatedByString:@"\n"];
        NSLog (@"%@",fileContents1);
        NSLog (@"%@",lines1);
    }
    else {
        NSLog(@"Nope there is no file");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The example below is from a REST database driver on Python 2.7. In the
The example below may not be problematic as is, but it should be enough
How can I combine two arrays it should be ordered like the example below?
The example below, is just an example, I know that I don't need an
this example below works when hover event is trigered and when its not, its
The example below shows the code I am using to test whether a user
JSFIDDLE EXAMPLE BELOW I want to make the following CSS layout and currently im
Consider the overly simplified example below; some of it written with pseudocode for brevity.
See the example below. <concat destfile=dest-file> <fileset dir=dir1 /> <!-- how to append the
In the .htaccess example below, if someone types in a URL like the following...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.