Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Buschmaster

macrumors 65816
Original poster
Feb 12, 2006
1,306
27
Minnesota
I have a UILabel that has text which will come in from an int. It comes in in this way because it is inside of a for loop where it keeps gaining more and more values. Here's how I'm setting the dictionary's value:
Code:
[myPlate setValue:[NSString stringWithFormat:@"%d",aInt] forKey:@"aKey"];

What happens here is that the string will come out but it becomes a huge number, like an identifier.

And if I leave off the string with format I get a warning and it causes the iPhone simulator to crash.

How can I maintain the ACTUAL value of the int and pass it into an NSString to be placed into a dictionary?
 

Buschmaster

macrumors 65816
Original poster
Feb 12, 2006
1,306
27
Minnesota
Changed it a bit, same problem...

Code:
int aInt = 0;

and

then
Code:
for(eachDictionary in theArray) {
		aInt = (int)[eachDictionary objectForKey:@"aKey"];
	
		totalInt += aInt;
	}

	NSString *myString = [NSString stringWithFormat:@"%d",totalInt];
	
	[myDictionary setValue:myString forKey:@"aKey"];


With totalInt being a property.
 

therevolution

macrumors 6502
May 12, 2003
468
0
Wait a sec... Looking at it again:

Code:
aInt = (int)[eachDictionary objectForKey:@"aKey"];

That doesn't look right. You're pulling an object pointer and casting it to int - almost certainly this is why you're seeing big numbers.

Do you know what those objects should be? If they're strings:

Code:
aInt = [(NSString *)[eachDictionary objectForKey:@"aKey"] intValue];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.