I have a method which calculates loan payments based on car price, interest rate and number of years, this method is in my model and is accessed through my main view controller.
I created a singleton in the model but since I created it the method that calculates the payments stopped working for some reason. I have made sure that I have created the shared instance, It was working before I implemented the singleton.
Any help would be appreciated. I have not received any errors.
Here is the singleton I created.
+(id) sharedCalculatorBrain
{
static id sharedCalculatorBrain = nil;
if (sharedCalculatorBrain == nil)
{
sharedCalculatorBrain = [[sharedCalculatorBrain alloc]init];
}
return sharedCalculatorBrain;
}
Here is how I have created the object.
CalculatorBrain * brain = [CalculatorBrain sharedCalculatorBrain];
and I call the method by using:
[brain calculatePaymentPlan:[self.txtLoanAmount.text doubleValue] :[self.txtInterestRate.text doubleValue] :[self.txtNumberOfYears.text doubleValue]];
Not sure if it is a typo, but check your code if you allocate the singleton instance using:
Because if this is the case, you need to do:
Hope this helps, good luck with your project!