-2

I have a method that receives an nsinteger, then I need to convert it to a nsnumber, but I get a really strange number, my code is:

+(TarefaMR *)GetTask:(NSInteger *)idTask {   
    NSLog(@"idTask %@",[NSNumber numberWithInteger:idTask]);
    NSInteger *tt=111;    
    NSLog(@"tt %@",[NSNumber numberWithInteger:tt]); 
}

my idtask is 888 and I get a 203513664 while the tt variable is working , I get the 111, what can be the problem?

Girish
  • 4,692
  • 4
  • 35
  • 55
edounl
  • 65
  • 1
  • 11
  • +(TarefaMR *)GetTask:(NSInteger *)idTask did you mean +(TarefaMR *)GetTask:(NSInteger)idTask – 0x8badf00d Jun 25 '13 at 12:20
  • `NSInteger` is a primitive type, a typedef to `int` or `long long`. It's **not a class.** Why you people don't read the documentation? –  Jun 25 '13 at 12:21
  • doesnt resolve the problem,keep getting a strange number – edounl Jun 25 '13 at 12:36
  • @user2069142 yes, it does if you look carefully what it means. Don't use a pointer to an NSInteger or you will just get the memory address instead of the value – Mario Jun 25 '13 at 12:39
  • i removed the * and i keep getting this number : 174447376 instead off 888 – edounl Jun 25 '13 at 12:58
  • Your doing something else wrong then! How to you call the method? – Mario Jun 25 '13 at 13:15
  • i have and object then use : currentTask.noteId=[[allDataDictionary objectForKey:@"noteId"]integerValue]; and i call the method like this [client GetTask:[current noteId]] in didSelectRowAtIndexPath; – edounl Jun 25 '13 at 14:05
  • make sure you accept the answers since they are right. – John Jun 25 '13 at 14:48
  • well, it might be, but i found the problem, it hadnt anything to do with this, sorry for the basic question... – edounl Jun 25 '13 at 16:59

1 Answers1

3

You shouldn't use NSInteger as a reference. Try removing the * from behind every mention to NSInteger you do. Remember, NSInteger are not objects, they're just a cool way to name "int"s :)

Girish
  • 4,692
  • 4
  • 35
  • 55
Bartserk
  • 675
  • 6
  • 18