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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:35:32+00:00 2026-06-11T17:35:32+00:00

Possible Duplicate: Unable to access object of other class I’ve been working on a

  • 0

Possible Duplicate:
Unable to access object of other class

I’ve been working on a little project just to increase my comprehension of the objective-c syntaxe and functionalities but I’m stuck in my own project and can’t find the answer.

First I’ve got two classes and in my main one I have declare a object of my other class so I can use the functions from my other class. This is how I did it (I just wrote the thing that I thought were necessary:

.h of my main class
import myOtherClass

@interface PkmViewController : UIViewController

    @property Pokemon * nomDePokemon;

.m of my main class
import myOtherClass

@synthesize nomDePokemon;

int nbDef = [nomDePokemon calculerUnNombrePourLaDefense];

.h of my other class

@interface Pokemon : NSObject

  @property int defencePoints;

-(int)calculerUnNombrePourLaDefense;

.m of my other class

@synthesize defencePoints;

-(int)calculerUnNombrePourLaDefense
{
    int nombrerandom = arc4random() % 45;
    return nombrerandom;
}

When I put a breakpoint in my main class to see what number is taken from the function, it always gives me 0. And when I put this section in my other class it works but I want to keep it in another class to improve my skills. Someone can explain me how to do it please?

  • 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-11T17:35:33+00:00Added an answer on June 11, 2026 at 5:35 pm

    It sounds like you haven’t actually assigned an instance of Pokemon to your nomDePokemon variable. This means that instead of a Pokemon object, the variable contains nil, which returns nil or 0 in response to any message you send it. To solve the problem, create a Pokemon.

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

Sidebar

Related Questions

Possible Duplicate: Type result with conditional operator in C# I was just working on
Possible Duplicate: Convert a JSON string to object in Java? I'm working on a
Possible Duplicate: Unable to Populate TableView In PopOverController - Objective C I am using
Possible Duplicate: check whether internet connection is available with C# I just want to
Possible Duplicate: What is the use of a Dispatcher Object in WPF? Sorry to
Possible Duplicate: Unable to get a list of installed Python modules How do I
Possible Duplicate: Can I turn off impersonation just in a couple instances I've created
Possible Duplicate: What's the difference between on and live or bind ? I've been
Possible Duplicate: Unable to change DataRow value I bound a datatable to a datagrid.
Possible Duplicate: Add picture at facebook event with Graph API I have been trying

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.