Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How would you make a folder that holds other folders inside?

There are different classes in 1 course so I am trying to make a folder that holds all the objectives but instead of all the objectives being saved in only one folder being saved in individual folders and all of them being saved in one folder. Like -

Main Folder) Folder 1 Inside Main Folder) Folder 2 Inside Main Folder) Folder 3 Inside Main Folder)

4 Answers

Ok, this is the closest I could get to what you are describing in Playgrounds. I had no idea that they could work this way, so I am glad you asked this question. Here we go!

Step 1:

  • create a new Playground, giving it the name you want your main folder to be. This Playground won't be used for any code, and after you go through the rest of the steps, it seems to just be a container for the rest of the pages you create.

Step 2;

  • Open the Navigator, which is near the top right hand side of the Playground you just created. These are the same controls you use in an Xcode project, hover your curser over each to see which is the Navigator. When clicked, it should open to the far left of your Playground, showing the name of the Playground you created.

Step 3:

  • at the bottom of the Navigator window, you will see a + sign. Click that and select New Page. Name it what you like, and proceed to code in this file. When created, they all seem to import Foundation, which you can change to UIKit if needed(or import whatever other 'kits' you need). This file will show in a drop down menu from the first(main) Playground you created.

Step 4:

  • when you want a different Playground, go click that + sign again, and you will get a new untitled Playground page. Do whatever code you need to do in this, and obviously name it different than the last one you created. You now have 2 separate Playgrounds, and only the one you have selected will compile. If there are errors in the others though, you will get error messages and may have to fix those before any code will compile in the one you are working on. Add as many pages as you like(using the + button, selecting New Page), I have tried about 7 extra pages so far and it seems to work fine. Not sure if there is a limit on how may you can have.

Whatever you named the ORIGINAL Playground will be the one that shows up on your computer(whether you save on Desktop, or external drive) so when you first open Xcode, you will open that Playground, and it will hold onto all the other Playgrounds you created. It doesn't seem to let you create folders, but this is what I think you are looking for. I am pretty jazzed about this myself, as it will make organizing my files so much better!

That's it! Enjoy your coding adventures:)

Dan

Amazing help! Thanks a lot!

Hey Luis,

There are a few ways to do this using Finder, but I will just tell you the from scratch method on your Desktop.

On your Desktop, right-click, and a menu will come up. The top option will be New Folder. Select that to create the first folder. Once that is created, double-click on it and a Finder window will open up with a bunch of empty space on the right, and your Mac folders(every other group on your computer) on the left. In that blank space on the right, right-click and select New Folder again. Now that second folder is inside the first. To add more, just keep going through the process of right-click in the blank space inside Finder and select New Folder each time. Create as many as you need and they will all be inside that first folder.

Does this help? If you are talking about inside Xcode though, it's a little different. If that's the case let me know and I will help if I can.

Dan

Thanks Dan for your help! Though I was taking about inside Xcode. Should of been more specific. Haha! Please help

Ah, I see. Well, if it is inside an Xcode project(not a Playground), you would just right-click on the main project folder(not the blue one at the top) and then go down and click on New Group, which will create another folder inside of the original one. No clue if you can do something like that in a Playground though. If I figure out something for Playgrounds, I will put another reply in this thread. For now, I can't seem to figure out if you can do this in a Playground.

Haha thanks but again I should have been more specific. Yeah I was trying to do it in a playground. Though now I have learned how to do it in a project, great help. If you would find out how to do it in a playground please let me know. Thanks!