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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:15:50+00:00 2026-05-27T17:15:50+00:00

I am trying to call a method that checks whether the player is bigger

  • 0

I am trying to call a method that checks whether the player is bigger or smaller than the enemy. (this is a fish game)

In EnemyFish.m I am using this method

-(void) compareSize:(Player*)player{
if (self.fSize > player.pSize){
    isBigger = true;
}
else{
    isBigger = false;
}

}

Then I want to call this method during the update so I am doing this:

-(void) update {
[self compareSize];

//Check to see if bigger than player fish
if( isBigger == true){
//code for if bigger
}else{ //etc.  }

I am getting an exception: sharedlibrary apply-load-rules all

not sure what the best way to set up this method would be, and the best way to call it, since [self compareSize] is definately not working.

Any help would be greatly appreciated, Thanks!

——UPDATE———-

What about if I use this

update:(Player *)player{

The problem I was running into here, is how to call this correctly, I wasn’t sure how to change this to correctly call the new update method:

[self schedule:@selector(update) interval:1.0f/60.0f];
  • 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-27T17:15:50+00:00Added an answer on May 27, 2026 at 5:15 pm

    It is unclear what you are asking, but let’s look at your code and see if it helps.

    Your first method can be written more concisely as:

    - (void) compareSize:(Player *)player
    {
       isBigger = self.fSize > player.pSize;
    }
    

    There is no point in using an if/else to assign a true/false (or YES/NO) value.

    Looking at this method raises the obvious question of whether it would be better returning a value rather than assigning to an instance variable. This would look like:

    - (BOOL) compareSize:(Player *)player
    {
       return self.fSize > player.pSize;
    }
    

    and now you can use a call to compareSize in an if.

    Assuming the second version of compareSize your second method is:

    -(void) update
    {
       //Check to see if bigger than player fish
       if ([self compareSize]) // OOPS, no Player
       {
          //code for if bigger
       }
       else
       {
         //etc.
       }
    }
    

    But this doesn’t work as you need an instance of Player to pass to compareSize:, e.g. [self compareSize:somePlayerInstance]. So you now have to ask yourself where you expect the Player to be found; it could be an argument to update (e.g. - (void) update:(Player *)somePlayerInstance), or you might have a method to call which returns a whole collection of players and you need to test against each one, etc., etc. I can’t give an answer as I’ve no idea of your game and algorithm!

    Following comment

    You must store a reference to your Player object somewhere in your application. If there is only a single player is Player designed as a singleton with a sharedInstance, or similarly named, class method that returns the single instance? If so then your update will contain:

    if ([self compareSize:[Player sharedInstance]])
    

    etc.

    Another design pattern is to have your application delegate store the reference and to provide a method (or property) for accessing it. Following this pattern (and making up a class MyDelegateApp and property player names) your code might look like:

    if ([self compareSize:((MyAppDelegate *)[NSApp delegate]).player])
    

    Yet another model is to create the single player in the application’s main XIB/NIB file – etc., etc., there are many application models!

    You “simply” (its not simple of course) need to design your application model so that your single player is accessible, one way or another, where you need it…

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

Sidebar

Related Questions

Here's what I'm trying to accomplish with this program: a recursive method that checks
I am working with ASP.net. I am trying to call a method that exists
I'm trying to call a Sort method that expects a parameter of type IComparer<object>
I'm trying to find the jQuery equivalent of this JavaScript method call: document.addEventListener('click', select_element,
I am trying to create a bad word filter method that I can call
I am trying to call the .ajax() method when a button with id=go is
I'm trying to call a Page Method using a jQuery 'attached' event function, in
i am trying to call a navite method defined in c++ from java, the
I'm trying to intercept a method call (afterInsert() of a domain class) in a
I'm trying to iterate over an enum, and call a method using each of

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.