Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 creating new objective C Class

Working on iOS7+8 with xcode6 and running into a weird issue...

I created the first viewController and thats fine, now I created another and I am trying to set that new viewController to a new class....

in xCode4 all I had to do was create new-->Objective C Class....but I don't see this option in xcode6. All I see is this swift stuff, but I want an objective C class!

I see I can make a new objective c file, but that doesn't really help me. I want to create both the .h and .m files.

Thanks in advance,

like image 614
Anon Avatar asked Sep 24 '14 06:09

Anon


People also ask

How do I create an Objective-C class in Xcode?

Creating a Class To make a new class in Xcode it is advised to make a new file separate from the other code and call the class. This can be done by making a new file. To make a new file, click on File, and then New → File. A selection screen will come up, for an iphone app, select cocoa touch and objective C class.

How do you create a class object in Objective-C?

Creating a Custom Class Go ahead an choose “Objective-C class” and hit Next. For the class name, enter “Person.” Make it a subclass of NSObject. NSObject is the base class for all objects in Apple's developer environment. It provides basic properties and functions for memory management and allocation.

How do I create a new class in Xcode?

To generate the class and properties files initially: From the Xcode menu bar, choose Editor > Create NSManagedObject Subclass. Select your data model, then the appropriate entity, and choose where to save the files. Xcode places both a class and a properties file into your project.


2 Answers

Create Cocoa touch file - that will generate both .h and .m, and you can choose either with or without a xib generated. Be sure to pick Objective-c as language - now it lets you pick either Objective-c or Swift.

like image 110
Peter Pei Guo Avatar answered Sep 24 '22 22:09

Peter Pei Guo


I had this same issue yesterday. The solution is simple:

1) File > New

2) Under IOS, click "Source"

3) Select "Cocoa Touch Class"

And then create your Class as you used to in Xcode 4. Now you should see your .h and .m files.

like image 26
Alan Scarpa Avatar answered Sep 24 '22 22:09

Alan Scarpa