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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:46:42+00:00 2026-06-06T11:46:42+00:00

So I have a generic question. I have a bunch of functions, some of

  • 0

So I have a generic question. I have a bunch of functions, some of which are void, some which return NSString*, some which return NSDictionary*, etc. I use these functions in a bunch of different classes. I want to just create a library .m file that I can include in the classes that use them, so I don’t have to copy and paste these functions all over the place. I’m pretty sure this shouldn’t be hard to do but I can’t seem to get this to work for anything but void functions.

Example:

//Library.h
(NSString*)doStuff{
    NSString* test = "hello world";
    return test;
}

(void)print{
    NSLog(@"Hi");
}

I wish to basically have 1 file that I can just use an import statement on, but am uncertain if this is possible in obj c.

Robin

  • 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-06-06T11:46:44+00:00Added an answer on June 6, 2026 at 11:46 am

    You can use the plain old C style:

    // ======== yourlib.h =========
    #import <Foundation/Foundation.h>
    NSString *doStuff();
    void print();
    
    
    //======== yourlib.m =========
    #import "yourlib.h"
    NSString *doStuff(){
        NSString *test = @"hello world";
        return test;
    }
    
    void print(){
        NSLog(@"Hi");
    }
    

    Or, you can use the category feature to attach to existing frameworks:

    // ======= youlib.h ========
    #import <Foundation/Foundation.h>
    @interface NSString (YourCategory)
    + (NSString *)someStringFromString:(NSString*)string;
    - (NSDictionary *)someDictionaryFromString;
    @end
    // ======= yourlib.m =======
    #import "yourlib.h"
    @implementation NSString(YourCategory)
    + (NSString *)someStringFromString:(NSString*)string {
       ...
       return aString;
    }
    - (NSDictionary *)someDictionaryFromString {
       ...
       return aDict;
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a more generic question, so I'm hoping someone here has some info
I have a generic question about javascript specification or implementation of functions pointer (delegates?)
I have a generic question about tableview Draw and reload data, and wanted some
I am aware of Web Services and WCF but I have generic question with
I have a generic question about scope and encapsulation. Take two scenarios: Scenario 1:
This may sound like a very generic question but here it goes. I have
I have a question, is this the correct approach to make a Generic Singleton?
I have generic list which must be a preserved order so I can retrieve
I have a Generic List object which hold below table as its own value.
I have two generic list objects, in which one contains ids and ordering, and

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.