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

  • Home
  • SEARCH
  • 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 6384987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:50:34+00:00 2026-05-25T02:50:34+00:00

I’m trying to separate the methods for the NSCoding into separate files from my

  • 0

I’m trying to separate the methods for the NSCoding into separate files from my actual classes. I know you can generally define new methods using Categories in Objective-C, but it seems Xcode still sends warnings when it doesn’t encounter the -encodeWithCoder: and -initWithCoder: methods in the master class file.

The reason I’m doing this (and hopefully this doesn’t sound too convoluted) is that I have many dozen classes spread across various files, and in order to avoid the tedium and redundancy of writing out encodeWithCoder:/initWithCoder: methods for each and every class, I put together a small script to automatically parse the header files and generate the necessary encoding/decoding code based on variable types and dump the results into a single Encoders.m. The result links properly, but I still receive the warnings during compilation “Incomplete implementation of class ‘MyClass'”, “Method definition for ‘-initWithCoder:’ not found” (etc), and “Class ‘MyClass’ does not fully implement the ‘NSCoding’ protocol”. I’ve tried simply adding the declarations to the classes’ .h files, but no go.

Is there any way to inform Xcode that the methods are in fact implemented, just not in the non-Category class file?

A simplified example:

MyClass.h

@interface MyClass : NSObject <NSCoding> {
    int num;              //@ENCODABLE
    float timer;          //@ENCODABLE
    SomeOtherClass *obj;  //@ENCODABLE
}
...
@end

MyClass.m

#import "MyClass.h"
@implementation MyClass
...
@end

Encoders.m

#import "MyClass.h"
@implementation MyClass (Encoding)
-(void) encodeWithCoder:(NSCoder*)encoder {
    // Auto-generated encoding of instance variables
}
-(id) initWithCoder:(NSCoder*)decoder {
    if (self = [self init]) {
        // Auto-generated decoding of instance-variables
    }
    return self;
}
@end
  • 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-25T02:50:35+00:00Added an answer on May 25, 2026 at 2:50 am

    Any methods which are declared in the class’s interface, a class extension, or a protocol which either the interface or extension specify, must be implemented in the main @implementation block, or you will receive a warning. There is no way to declare a method in those places and tell the compiler it will be in a category. What you can do is create a category interface and declare the NSCoding protocol there. If you add this interface to your main header file, any files which import the header will know that the class supports coding, but the compiler won’t complain that the methods aren’t implemented.

    New MyClass.m

    @interface MyClass : NSObject {
        int num;              //@ENCODABLE
        float timer;          //@ENCODABLE
        SomeOtherClass *obj;  //@ENCODABLE
    }
    ...
    @end
    @interface MyClass (Encoding) <NSCoding>
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.