Aastha
Aastha

Reputation: 23

How to create a .m file corresponding to a .h file in xcode

When I try to create a .m file from the file menu, it prompts me for choosing a template from the several types mentioned - Objective-C class, Objective-C category, Objective-C protocol, etc.. Which one should be preferred?

I am fairly new to Objective-C as well as Xcode, so pardon me if this question is too obvious.

Upvotes: 1

Views: 9325

Answers (2)

camilomq
camilomq

Reputation: 3031

If you want to create just an empty .m file, you can do so following these steps (Xcode 5.1.1):

  • In your Xcode project, go to File --> New --> File...
  • Select Other --> Empty
  • Click on Next
  • Type a name for your file and be sure to finish it with extension .m
  • Click on Create to save it

Upvotes: 1

thatzprem
thatzprem

Reputation: 4767

  • You may have to add Objective-C class and rename the new.m alone to match your old.h and remove the newly added new.h file.
  • Create a new Objective-C class and copy your code from old.h to new.h file

Update as per comments: I see you are trying to add .m for the MAC sdk library, which is not possible.

You may have to consider using Categories extending the existing class methods.

What is “category

Customizing Existing Classes

Upvotes: 2

Related Questions