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

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -