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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:37:46+00:00 2026-05-22T12:37:46+00:00

// 9.1.h #import <Foundation/Foundation.h> @interface Complex : NSObject { double real; double imaginary; }

  • 0

// 9.1.h

#import <Foundation/Foundation.h>


@interface Complex : NSObject 
{

    double real;
    double imaginary;

}

@property double real, imaginary;
-(void) print;
-(void) setReal: (double) andImaginary: (double) b;
-(Complex *) add: (Complex *) f;

@end

#import "9.1.h"


@implementation Complex

@synthesize real, imaginary;

-(void) print
{
    NSLog(@ "%g + %gi ", real, imaginary);
}

-(void) setReal: (double) a andImaginary: (double) b
{
    real = a;
    imaginary = b;
}

-(Complex *) add: (Complex *) f
{
    Complex *result = [[Complex alloc] init];

    [result setReal: real + [f real] andImaginary: imaginary + [f imaginary]];

    return result;

}
@end

On the final @end line, Xcode is telling me the implementation is incomplete. The code still works as expected, but I’m new at this and am worried I’ve missed something. It is complete as far as I can tell. Sometimes I feel like Xcode hangs on to past errors, but maybe I’m just losing my mind!

Thanks!
-Andrew

  • 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-22T12:37:47+00:00Added an answer on May 22, 2026 at 12:37 pm

    In 9.1.h, you have missed an ‘a’.

    -(void) setReal: (double) andImaginary: (double) b;
    //                       ^ here
    

    The code is still valid, because in Objective-C a selector’s part can have no name, e.g.

    -(id)initWithControlPoints:(float)c1x :(float)c1y :(float)c2x :(float)c2y
    //                                    ^           ^           ^
    

    these methods are called as

    return [self initWithControlPoints:0.0f :0.0f :1.0f :1.0f];
    //                                      ^     ^     ^
    

    and the selector name is naturally @selector(initWithControlPoints::::).

    Therefore, the compiler will interpret your declaration as

    -(void)setReal:(double)andImaginary
                  :(double)b;
    

    since you have not provided the implementation of this -setReal:: method, gcc will warn you about

    warning: incomplete implementation of class ‘Complex’
    warning: method definition for ‘-setReal::’ not found
    

    BTW, if you just want a complex value but doesn’t need it to be an Objective-C class, there is C99 complex, e.g.

    #include <complex.h>
    
    ...
    
    double complex z = 5 + 6I;
    double complex w = -4 + 2I;
    z = z + w;
    printf("%g + %gi\n", creal(z), cimag(z));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

//SomeObject.h #import <Foundation/Foundation.h> @interface SomeObject : NSObject { } @property NSInteger aProperty; @end //main.m
operator class: #import <Foundation/Foundation.h> @interface operator : NSObject { int number; } @property int
Following is my code: .h file: #import Foundation/Foundation.h @interface GObject:NSObject{ NSTimer* m_Timer; } @property(nonatomic,
//////////////////// Mutation.h #import <Foundation/Foundation.h> @interface Mutation : NSObject @property (assign) NSString *inputString; @property (assign)
MPPopoverControllerDelegate.h file #import <Foundation/Foundation.h> @class MPPopoverController; @protocol MPPopoverControllerDelegate <NSObject> @optional - (void)popoverControllerDidDismissPopover:(MPPopoverController *)popoverController; @end
I've got this code: Entry.h #import <Foundation/Foundation.h> @interface Entry : NSObject { id object;
#import <Foundation/Foundation.h> #import Dropbox_Manager.h @interface FileSystemManager : NSObject { NSFileManager *fileManager; BOOL fileExisting; BOOL
I subclassed NSObject: #import <Foundation/Foundation.h> @interface STObject : NSObject { NSString *message_type; NSString *twitter_in_reply_to_screen_name;
I have a class DataObject as Header ::: #import <Foundation/Foundation.h> @interface DataObject : NSObject
If I have a custom class called Tires: #import <Foundation/Foundation.h> @interface Tires : NSObject

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.