Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:12:34+00:00 2026-05-24T18:12:34+00:00

Baby new to Xcode, Cocoa touch and iOS development in general. And am taking

  • 0

Baby new to Xcode, Cocoa touch and iOS development in general. And am taking the Stanford walkthrough for their iPhone class. I am a little confused at a couple of places and need to shoot my doubts to you guys:

I have two classes that I have created for my model, essentially CalculatorBrain.m and CalculatorBrain.h.
From what I gather, in Objective C, creating a class essentially consists of two functions, one is to declare the class which contains the method/messages and other variables while the other is the actual implementation for the same. From this stems two questions:

  1. Why must I declare a class without implementing it’s methods at first? (the concept seems to be borrowed from interfaces) and only then move on to implementing it .

  2. From the above question, as I go through the walkthrough, I notice that the class declaration took place in CalculatorBrain.h whereas the methods were actually implemented in CalculatorBrain.m. I am unable to grasp the nuances of why this was done so if anybody is willing to shed some light on this, it would really help

Thanks again,

Parijat Kalia!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:12:35+00:00Added an answer on May 24, 2026 at 6:12 pm

    These are traditions from the C world, and they’re just common practice to avoid some problems. They aren’t two classes, they are the definition (in the .h file) and the implementation (in the .c or .cc file).

    If you defined the class in the .c file, you couldn’t refer to it elsewhere because it wouldn’t be defined. You could include your .c file, but then you’d have two copies of the code. You could also use the “extern” keyword, but at this point it’s kind of odd.

    If you put code in the .h file, then when it’s included the code gets included. This means you can get compiler errors that you have three “getMyThing” functions.

    This means you can give out your headers to others without giving away your top-secret implementation (useful for making libraries), include your header without worrying about the possible multiple definitions, etc. You can also add variables and functions in the .c file which people using the header (like your other code) can’t see or use, so you don’t have to worry about changing it later and having compilation break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iphone development. I am old School - I was tought
A friend of mine sent me this code snippet to celebrate his new baby
I am new to the iPhone SDK and am trying to create 3 views
I'm taking my first baby steps into consuming web services. Here's my situation: I'm
I'm getting to know Mono development in Linux, in baby steps. I'm trying to
As you probably know, Derek Sivers is the guy who created CD Baby and
Possible Duplicate: New Cool Features of C# 4.0 Hello, There are several(many) questions at
I'm writing Baby's First Web Application. My first task has been to set up
I'm still super new with Rails, and just trying to get my first has_many
I'm still learning (baby steps). Messing about with a function and hoping to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.