5 Replies Latest reply: Feb 25, 2013 12:08 PM by Frank Caggiano
todrico Level 1 Level 1 (0 points)

I am working on some Obj-C excercises from "Programming in Objective-C". I would like to keep each excercise as a separate project for future reference. Currently I am creating a new project and then copy / paste the main.m code from a previous exercise which is a pain. I am working as an individual on a Mac-Mini and not in a shared environment. What information I have seen is geared for a shared multi-developer environment. Or, is there a way to open a project and rename - "save as" -  it like you can do with a Word document. Thanks.

Xcode, OS X Mountain Lion (10.8.2)
  • Frank Caggiano Level 7 Level 7 (25,715 points)

    You could duplicate the project but to be honest I'm having trouble understanding both what you are attempting to do and what your difficulty is with Xcode.


    Each exercise as a separate project is a good idea, why is cutting and pasting (not that this is necessarily the best way to go) a problem. If you open both the old and new projects and bring up the main.m in each  copying from one to the other shouldn't be to hard. How much code are you talking about?


    Depending on how much code you're talking about you could create code snippets and then you could just drag in the snippet. Or create a separate .m file withthe common code and use that in all the projects.



  • todrico Level 1 Level 1 (0 points)

    Just to let you know, I am new to Apple OS and Xcode. My experience is mostly with Windows. Many of the excercises are different and separate. Some build on top of the previous excerise. Yes, I can open a separate window copy and paste. But, mistakes can easily made that way.  I would prefer to be able, just like a Word doc or a Excel spreadsheet, open the file, perform a "save as" with a different file or project name then move on and make my changes. I am not familiar with code snipets. Besides this isn't a project where you drag and drop usable code. These are exercises which cover different topics and many times unrelated to the next chapter.



  • Frank Caggiano Level 7 Level 7 (25,715 points)

    If you are new to Xcode you might want to take a few days to get familiar with it. It is a very powerful Integrated Development Environment (IDE) and will take some time to get comfortable with. You might want to pay particular attention to the source code control tools built in to Xcode.


    You can take a snapshot of your project and use that to restore it to a particular state or use GIT and do true source code control.


    There is no 'save as' in Xcode, it really doesn't make sense given Xcodes environment. As I wrote you can try the File->Duplicate.. command to see if that does what you are looking to do. Or you could just duplicate the whole Xcode project structure in Finder.


    Perhaps if you described your workflow some other method to achieve it could be suggested.



  • todrico Level 1 Level 1 (0 points)

    I understand IDE's add more to the complications. Not like years ago when I was programming in C and all you had was your source file and header files. Then it was easy to copy and rename. I was just hoping there was that option in Xcode. I have gone through an Xcode tutorial and probably will again. Rather than spinning my wheels and wasting valuable learning time I was hoping someone would know a short cut. Thank you for lending an ear and valuable advice.

  • Frank Caggiano Level 7 Level 7 (25,715 points)

    Yep things have changed no doubt about it. But in this version of Xcode Apple has finally got a really nice tool.


    Again try the File->Duplicate command it may do what you are looking for.


    regards and good luck