views:

10

answers:

1

Hi,

Wondering what I am doing wrong here. I am trying to pass an integer to my custom class and when I output the argument in the function is is some random number instead of what I pass. Here is my method call in RootViewController.m:

    int orgID = organObj.organID;

NSLog(@"OrganID from RVC: %d", orgID); // this outputs the correct number

[Procedure getDatabase:[appDelegate getDBPath] WithOrganID:[NSNumber numberWithInt:orgID]];

Here is the implementation of my method:

   + (void) getDatabase:(NSString *)dbPath WithOrganID:(NSNumber *)organID
{
    NSLog(@"OrganID from procedure.m: %d", organID); // this outputs some random number
}

It's probably something trivial but I can't figure it out.

Thanks in advance.

A: 

organID is still an object reference. %d wants an actual integer, so you end up printing the number of the object pointer, or something similarly useless. use the -intValue method to get the actual integer back.

NSLog(@"OrganID from procedure.m: %d", [organID intValue]);
quixoto
Great! worked like a charm, knew it was something simple. Cheers!
Mark Cicero