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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:37:58+00:00 2026-06-17T13:37:58+00:00

I have created two classes, one for StockHoldings, and the other Portfolio (an array).

  • 0

I have created two classes, one for StockHoldings, and the other Portfolio (an array). I created the values in main and am trying to add the created stock values into the portfolio, but when I do it I get “incompatible pointer types sending…”

This is what I have in main:

Portfolio *thisPortfolio = [[Portfolio alloc] init];

[thisPortfolio addPortfolioObject:[stockOne valueInDollars]];

Even if I just try and put an integer in place of [stockOne valueInDollars] which is a method of that calculates a stock’s value based off instance variables in stockholding, then I get “Implicit conversion of ‘int’ to ‘Portfolio’…”

This is what I have in the Portfolio.h file:

@interface Portfolio : NSObject
{
    NSMutableArray *myPortfolio;
}

- (void)addPortfolioObject:(Portfolio *)a;

And this is what I have in the Portolfio.m file:

- (void)addPortfolioObject:(Portfolio *)a
{
    // Is assets nil?
    if (!myPortfolio) {

        // Create the array
        myPortfolio = [[NSMutableArray alloc] init];

    }
    [myPortfolio addObject:a];
}

What am I doing wrong?

  • 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-17T13:37:59+00:00Added an answer on June 17, 2026 at 1:37 pm

    In the interface of Portfolio, indeed you declare the signature of addPortfolioObject such that a Portfolio object is expected, not an integer. The signature will have to change to (void)addPortfolioObject:(int)a both in the interface and the implemention. The latter will have to wrap a in an NSNumber using numberWithInt because NSArray can only store NSObjects while int instead is a base type.

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

Sidebar

Related Questions

I have two classes. One is Main and the other is HelloWorld. When I
I have created two viewController classes such that one is superclass of another.i have
Suppose I just created a package example and have two classes inside it, Main
I have two basic questions. The first one is about function in other classes.
I have created two classes that implement AuthorizeAttribute . One is used globally, and
I have two classes, one Circle() and the other GeometricObject(). I have to extend
I have two classes, one AnalogClock class and one MainInterface class. I've created a
Say I have two classes created work and workItem. CWorker *work = new CWorker();
I have two classes with many-to-many relation so I created a join table in-between
I have two model classes, say parent and child. Parents are created first, 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.