Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Draw This
($0.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-28-2009, 11:06 AM   #1 (permalink)
MasterD
New Member
 
Join Date: Jul 2009
Posts: 7
MasterD is on a distinguished road
Unhappy Values becoming 0

Hi Im having a problem, where I'm trying to add a object to an array, when I do this, my values for that object become 0. I have yet to understand why.

Here is the bit of code.

Code:
int max = 100;
NSLog(@"%d",[[currentProblem arguments] count]);
for(int i = 0; i < [[currentProblem arguments] count]; i++) {
	if([[currentProblem arguments] objectAtIndex:i] != NULL) {
		PieChartData *myData = [[PieChartData alloc] init];
		NSLog([[currentProblem arguments] objectAtIndex:i]);
		[myData setName:[[currentProblem arguments] objectAtIndex:i]];
		max = [self randomNumberWithMax:max];
		[myData setValue:max];
		NSLog(@"%d",max);
		[diagramData addObject:myData];
		NSLog([[diagramData objectAtIndex:i] name]);
		NSLog(@"%d",[[diagramData objectAtIndex:i] value]);
		[myData release];
	}
}
____

this is my PieChartData

____ .h
Code:
@interface PieChartData : NSObject {
	int value;
	NSString *name;
}

@property (nonatomic, retain) NSString *name;
@property int value;
_____ .m

Code:
@implementation PieChartData

@synthesize value;
@synthesize name;
___

When I ask it to print to the log the number max it does, and its != 0 then when i ask it to print the value of the object. i get 0... HELP!

Here is an example of what my console prints:
Code:
5
America
randomNumberWithMax
49
0
Asia
randomNumberWithMax
37
0
Europe
randomNumberWithMax
12
0
Africa
randomNumberWithMax
8
0
Australia
randomNumberWithMax
4
0
MasterD is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,014
Threads: 93,862
Posts: 401,916
Top Poster: BrianSlick (7,962)
Welcome to our newest member, Shimi574
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.