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 7700313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:40:46+00:00 2026-05-31T22:40:46+00:00

I am reading about iOS programming and I bought the Programming iOS 4 book.

  • 0

I am reading about iOS programming and I bought the Programming iOS 4 book. There is a introductory part where among several things “Files” is mentioned.

I don’t understand how the source files is put together. You have a header file with function declarations, then you have a corresponding file with the function definitions.

Let say you have a Car.h and Car.m & Person.h and Person.m.

Now, if you want to use the Car in the Person class you would import only the Car.h file. How is this sufficient? I don’t understand the sequence it put together and builds a program. (Not thinking about the technical stuff, just h/m files.)

  • 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-31T22:40:48+00:00Added an answer on May 31, 2026 at 10:40 pm
    • The .h or “header file” contains the interface.
    • The .m or “implementation file” contains the implementation.

    Each implementation file is also called a “compilation unit” because the compiler compiles each one separately. Within each compilation unit, the compiler needs to know about types and methods. All it needs to know about a class to create the right code is information about the methods it implements.

    So let’s imagine you have these files:

    Car.h

    #import <Foundation/Foundation.h>
    
    @interface Car : NSObject
    - (void)drive;
    @end
    

    Car.m

    #import "Car.h"
    
    @implementation Car
    
    - (void)drive {
        NSLog(@"I'm driving!");
    }
    
    @end
    

    Person.h

    #import <Foundation/Foundation.h>
    
    @class Car;
    
    @interface Person : NSObject
    
    @property (nonatomic, strong) Car *car;
    
    - (void)start;
    
    @end
    

    Person.m

    #import "Person.h"
    #import "Car.h"
    
    @implementation Person
    
    @synthesize car;
    
    - (void)start {
        [car drive];
    }
    
    @end
    

    Now when the compiler does its business, it compiles both Car.m and Person.m into Car.o and Person.o respectively. [These then get linked into the final binary, but that’s beyond the scope of this question for now].

    When it compiles Person.m, the compiler doesn’t need to know how - (void)drive of Car is implemented, but it does need to know that it exists, that it is a method that takes no arguments and returns nothing. It doesn’t care about the implementation, just that it exists. So you just need to #import the header file of Car to tell the compiler about the methods that exist on Car. The compiler knows that the implementation exists, because you’ve told it so, and then later on the linker will do it’s business to correctly wire up the method call to the correct implementation. How the linker actually does that is a huge topic and I encourage you to go and read about it separately if you don’t already understand it.

    Note that it’s the same for all of the standard NS classes that you use such as NSObject, NSString, etc. You just need to #import Foundation.h from the Foundation framework which tells the compiler about what these classes are and what methods are defined on them.

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

Sidebar

Related Questions

I'm reading a book about iOS (it calls Programming iOS 4, by Matt Neuburg)
I'm reading through the Big Nerd Ranch book on iOS programming and I had
When reading about pipes in Advanced Programming in the UNIX Environment, I noticed that
I'm quite new to iOs Programming.. At the moment I'm wondering about following issue.
When I'm reading the apple iOS Developer Guide, it explains me a bit about
So I have been doing a lot of reading about the way iOS handles
I've been reading a book about design patterns for Objective-C and many times I've
I remember reading somewhere about multi-column indexing in Core Data (iOS), but I can't
Reading about the Dispose pattern , I see the documentation repeatedly refer to cleaning
Reading about Kohana templates and saw something I've never seen before: $this->template->title = __('Welcome

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.