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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2009, 12:06 PM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 7
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
Old 07-28-2009, 12:21 PM   #2 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 7
Default SOLVED

SOLVED
MasterD is offline   Reply With Quote
Reply

Bookmarks

Tags
help!, object, objective - c

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 245
23 members and 222 guests
ADY, Alsahir, beleg_1998, Dani77, diyora, FAED, fredidf, iDifferent, iph_s, JamesCahall, JasonR, mer10, Monstertaco, prchn4christ, Robiwan, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, timle8n1, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:13 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0