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 8105641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:13:01+00:00 2026-06-06T00:13:01+00:00

I would like to assign a variable instead of the string in my following

  • 0

I would like to assign a variable instead of the string in my following code.
First i am creating an array from comma separated list of directories. Next for each directory in the array, i want to create them, if they doesn’t exist.

How do i assign the directory from the array rather than: @”templates/standard1/css”
I have tried replacing it with s, but that didn’t work out. I can NSlog the s, but it doesn’t seem to create the directories.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *theString = @"templates, templates/standard1, templates/standard1/css, themes, themes/plain, themes/plain/384";
NSArray *items = [theString componentsSeparatedByString:@","];
for (NSString *s in items) {
    NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"templates/standard1/css"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
        // Directory does not exist so create it
        [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:YES attributes:nil error:nil];
    }

}

Any help would be appreciated 🙂

  • 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-06T00:13:02+00:00Added an answer on June 6, 2026 at 12:13 am

    I think the spaces are bothering your directories. You have each directory separated by “, ” but are searching for “,” (without a space). You can either take the spaces out of your theString, or use “, ” as your separator, for using the string!!!

    So either change

    NSString *theString = @"templates, templates/standard1, templates/standard1/css, themes, themes/plain, themes/plain/384";
    

    to this

    NSString *theString = @"templates,templates/standard1,templates/standard1/css,themes,themes/plain,themes/plain/384";
    

    Or Change this:

    NSArray *items = [theString componentsSeparatedByString:@","];
    

    to this:

    NSArray *items = [theString componentsSeparatedByString:@", "];
    

    BUT NOT BOTH!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to assign a static list of items in a SelectList() to
I am fetching an array and I would like to assign attributes of items
I have a jpeg file saved in a string. I would like to load/assign
I would like to assign a function's contents as text to a variable, so
I would like to define the following function in Objective-C. I have provided pseudo-code
I would like to assign a variable inside an $.ajax() function so that it's
I would like to try to assign a variable value to input hidden field
I have a JQuery plugin function where I would like to assign selectors from
If I would like to assign a class to my embedded ruby form, like
I have a Customers table and would like to assign a Salesperson to each

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.