ios - Best way to pass variable to a Class/Instance? -


i have instance returns distance earth sun depending on day of year. calculates today's date internally self-contained. want change pass day of year integer. best way , have options?

-(double) calculatedistrancefromsun {     // calculate day of year     nscalendar *gregorian = [[nscalendar alloc] initwithcalendaridentifier:nsgregoriancalendar];     nsuinteger dayofyear = [gregorian ordinalityofunit:nsdaycalendarunit inunit:nsyearcalendarunit fordate:[nsdate date]];     setdayofyear = dayofyear;      // source: curious.astro.cornell.edu/question.php?number=582     double rad2deg       = pi/180;     double theta         = (dayofyear/(daysinyear/360)*rad2deg);     double cc            = cos(theta);     setdistancefromsun   = semimajoraxis*(1-pow(eccentricy,2))/(1+eccentricy*cc);     return setdistancefromsun; } 

-(double) calculatedistrancefromsunwithdate:(nsdate *)date {     // calculate day of year     nsuinteger dayofyear = [gregorian ordinalityofunit:nsdaycalendarunit inunit:nsyearcalendarunit fordate:date];     setdayofyear = dayofyear;      // source: curious.astro.cornell.edu/question.php?number=582     double rad2deg       = pi/180;     double theta         = (dayofyear/(daysinyear/360)*rad2deg);     double cc            = cos(theta);     setdistancefromsun   = semimajoraxis*(1-pow(eccentricy,2))/(1+eccentricy*cc);     return setdistancefromsun; } 

Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -