Spot the problem

1 view
Skip to first unread message

Jason Martens

unread,
May 9, 2009, 3:28:26 PM5/9/09
to rtfm-development-...@googlegroups.com
Hey guys,
   I've been staring at this for a while, and I can't figure out what the problem is.  The compiler is giving a warning:

warning: passing argument 1 of 'addObject' makes pointer from integer without a cast

On the [recipeIdArray addObject:currentRecipe.primaryKey]; line.  I have tried it with and without casting, but it still complains.  currentRecipe.primaryKey is of type NSInteger.

Thoughts? 
Thanks,
Jason

- (void)saveCurrentMenu {
NSMutableArray *recipeIdArray = [[NSMutableArray alloc] initWithObjects:nil];
for (Recipe *currentRecipe in menu) {
[recipeIdArray addObject:currentRecipe.primaryKey];
}
[[NSUserDefaults standardUserDefaults] setObject:recipeIdArray forKey:kMenuArrayKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}


Thoughts? 

Thanks,
Jason

DavidK

unread,
May 9, 2009, 3:31:17 PM5/9/09
to RTFM: Development for Mobile Devices
NSInteger isn't an object it's typedeffed to int. You can only add
true NSObjects to NSArrays

DavidK

unread,
May 9, 2009, 3:35:43 PM5/9/09
to RTFM: Development for Mobile Devices
To clarify, what you should do is [recipeIdArray addObject:[NSNumber
numberWithInt:currentRecipe.primaryKey]];

Jason Martens

unread,
May 9, 2009, 3:46:50 PM5/9/09
to rtfm-development-...@googlegroups.com
Thanks David, that did the trick.

Booya! Saving works!
Reply all
Reply to author
Forward
0 new messages