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

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

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-15-2009, 05:53 PM   #1 (permalink)
haydnw
New Member
 
Join Date: Mar 2009
Posts: 5
haydnw is on a distinguished road
Default Debugger says variable is "Out of scope"

I have a method which has suddenly started giving me some problems. It starts like this:

Code:
- (double) calcJulianDayNumber: (NSDate *) dateToConvert {
	
	// Get the day, month and year
	NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
	[dateFormatter setDateFormat:@"M"];
	double month = [[dateFormatter stringFromDate:dateToConvert] doubleValue];
	[dateFormatter setDateFormat:@"YYYY"];
	double year = [[dateFormatter stringFromDate:dateToConvert] doubleValue];
	[dateFormatter setDateFormat:@"d"];
	double day = [[dateFormatter stringFromDate:dateToConvert] doubleValue];
	[dateFormatter release];
	
	// Work out Julian Date / Julian Day Number
	...
And is called like this, in the same class:

Code:
- (void) refresh: (NSDate *) dateToRefreshTo {
	workingJDN = [self calcJulianDayNumber:dateToRefreshTo];
	...
However, when I run the code, the iPhone simulator crashes. The debugger tells me that 'dateToConvert' on the line
Code:
double month = [[dateFormatter stringFromDate:dateToConvert] doubleValue];
is "Out of scope".

The only problem I can think is that I'm calling refresh:aDate from a different class. This could mean that if I'm passing things by reference rather than by value, then in the methods above I'm trying to access a variable which belongs to the calling class, not self. Which I guess isn't allowed. Right?

As you can tell, I'm new to all of this! Any guidance or general thoughts would be much appreciated!
haydnw is offline   Reply With Quote
 

» Advertisements
» Online Users: 446
13 members and 433 guests
baja_yu, buggen, CatfishBlues Games, ChrisYates, foany, HowEver, IphoneSdk, Kieren Harrold, mer10, Paul Slocum, Rudy, ryantcb, TheStalker
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,635
Threads: 94,096
Posts: 402,802
Top Poster: BrianSlick (7,990)
Welcome to our newest member, sadevb61
Powered by vBadvanced CMPS v3.1.0

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