Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
December 16, 2017, 09:26:00 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: question about importing classes  (Read 2330 times)
sir
Full Member
***
Posts: 118


Email
« on: March 15, 2009, 12:26:26 AM »

Hey Everyone,

How do I import classes that I have written into my project.  I am working on an exercise in Chapter 8, and I want to use the Rectangle and XYPoint classes I made in another exercise.  When I paste the files into my project folder in finder, it does not show up in my project browser in X code.  When I put these classes and their methods in my main, it does not recognize them.  I would assume there would be an easier way then having to create a new class each time and then paste the code in.

Nicholas
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #1 on: March 15, 2009, 02:16:08 AM »

Hi,

To add a new class in Xcode, select File->New File  then select Objective-C class. 

If the class already exists, just right click on Classes in Xcode's left pane, select Add->Existing Files, then select your .m and .h files. 

Hope this helps.

Cheers,

Steve Kochan


Logged
sir
Full Member
***
Posts: 118


Email
« Reply #2 on: March 15, 2009, 06:21:33 PM »

Perfect, exactly what I needed to know.

I was also wondering...  Is it possible to have multiple super-classes for a class?  Meaning, can I import more than one class and perhaps type in the header:

@interface Class3: Class2, Class1

where Class2 and Class1 are independant classes?

Thanks,
Nicholas
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114



« Reply #3 on: March 15, 2009, 06:26:38 PM »

Nope, just one superclass.  Many classes can have the same superclass, but a class can only have one superclass.

Cheers,

Steve
Logged
adamgonzalez1984
Jr. Member
**
Posts: 89


« Reply #4 on: March 16, 2009, 07:39:49 AM »

I believe you can also drag and drop into the "Groups & Files" field in xcode.  I think you have to be holding the option button when you try to drag over your classes. 
Logged
dennishenley
Newbie
*
Posts: 12


« Reply #5 on: September 28, 2011, 11:48:06 AM »

In Xcode 4.0.2 I got to Files > Add Files to "name of project" and then navigate to where the .h and .m files are and select them.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.