Reputation: 93
I know I'm missing something obvious here but I can't seem to get my nsinteger stuff write for passing variables and putting them into strings. Here is the part of code that is jacked up.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *chosenCell = [tableView cellForRowAtIndexPath:indexPath];
//need to get the ID number for this guy
NSInteger id_number = chosenCell.tag;
NSLog(@"This is the id number I'm sending to the item list %@", id_number);
NSLog(@"This is the id number I'm sending to the item list %i", id_number);
ItemViewController *vc = [[ItemViewController alloc] initWithPlayer:id_number andGame:gameId];
[[self navigationController] pushViewController:vc animated:YES];
[vc release];
}
The problem is that if I print using the %@ it works properly, however it really shouldn't as this is not an object that is being printed but an integer. If I use the integer call, it functions wrong, giving me a really off the wall integer. This sounds like the answer is just "use %@" but the problem is that in other cases when I tried to use that as the solution(such as on the next controller), I get an exc_bad_access. Please tell me I'm missing something obvious here...
Upvotes: 1
Views: 215
Reputation: 8515
%i
will work, according to Apple's Documentation.
A UIView
's tag is an NSInteger, which is what %i
specifies.
Upvotes: 1
Reputation: 19897
To work on both 32 bit and 64 bit systems you should correctly use %ld
or %lx
as specified in the apple documentation here (under the heading Platform Dependencies):
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
Edit: Ah. Sorry. This is iOS not Mac OS.
Upvotes: 1