iosobjective-cinttheoslogos

Get function data from inside a method (Simple code included)


Currently trying to access information stored in this method

   -(long long)numberOfPages;

trying to do so while already inside another method using logos

heres what it looks like, can you help me get it working? thanks

-(double)_spacing {

if (numberOfPages == 3) {
//execute code
}
else {
//do this


  }
}

need to determine the number of pages on the device using that method, help appreciated this should be pretty easy for an experienced coder. my googling has led me to believe i might need to use interface?


Solution

  • When you enter just numberOfPages you are writing a variable reference, and of course you do not have a variable but a method. Methods need to be called:

    if ([self numberOfPages] == 3) ...
    

    In this case as the method takes no arguments and returns a simple value you can also treat it as the "getter" of a property and call it using property accessor syntax:

    if (self.numberOfPages == 3) ...
    

    HTH