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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:04:36+00:00 2026-05-27T09:04:36+00:00

I’ve been learning Obj-C since getting a MBP about a month ago. I’m fairly

  • 0

I’ve been learning Obj-C since getting a MBP about a month ago. I’m fairly comfortable with what I’m learning & things are slotting in to my rusty old brain pretty well. Except there’s one thing I’m just not sure if I’m overlooking, or if just going over my head, or I’m looking for something that isn’t there.

Most languages I’ve used have a way of slotting in an inline function call to simplify the coding, & I’m just not sure how this translates in Obj-C. Especially I’m referring to when the function being called is in a separate file, for the coding purposes of keeping similar functions together.

So far, the only way I’ve seen in Obj-C guides & tutorials is to create a class with methods & then instantiate that class (within the class you’re working) to access the method in a [message]. Is this the way it’s done in Obj-C? The only way? The best way for some reason? I know classes have their place in many languages & I use them myself, but I’m referring to simple little inline function calls where I usually wouldn’t go to the trouble of creating a complete class.

To use a simple C++ console example of my point (only showing the .cpp files):

// example mainFile.cpp
#include <iostream>
#include "mainFile.h"
#include "functionsFile.h"
using namespace std;

void theMainFunction () {
    int resultBeforeAltering = 100;
    // alterTheResult() = simple inline function call I'm referring to
    cout << "The result is " << alterTheResult(resultBeforeAltering);
}

.

// example functionsFile.cpp - could contain many similar functions
#include "functionsFile.h"

int alterTheResult (int resultToAlter) {
    int alteredResult;
    if (resultToAlter < 100) {
        alteredResult = resultToAlter * 2;
    } else {
        alteredResult = resultToAlter * 3;
    }
    return (alteredResult);
}

Is there an equivalent approach to do alterTheResult() in Obj-C (assuming mainFunction() was an Obj-C method)?

I’ve seen reference to functions within Obj-C, but they seem to be C functions being referred to. C functions are not what I’m asking about here.

Thanks in advance, answers much appreciated.

  • 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-27T09:04:37+00:00Added an answer on May 27, 2026 at 9:04 am

    Yes, the way to inline is to use C or C++ inlining — that’s perfectly legal (for C++, that will require compiling as ObjC++). An ObjC method will never be inlined (until LLVM produces a JIT compiler =p).

    If you simply want to organize methods in another file, you may want to try an ObjC category:

    // NSString_MONStuff.h
    @interface NSString (MONStuff)
    - (BOOL)mon_isPalindrome;
    @end
    
    // NSString_MONStuff.m    
    @implementation NSString (MONStuff)
    - (BOOL)mon_isPalindrome { return ...; }
    @end
    

    Again, those will not be inlined.

    You can also use C or C++ external functions or classes instead of categories for organization – the benefit is speed, size, reduced dependencies, and safety. The choice is yours, but there’s no way to inline an objc method (it’s a very dynamic langauge).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.