As my projects are growing I am trying to develop better habits which I mentioned before. I use this code a lot to get a path to a plist located locally.
A number of viewControllers would access this code. To save space, duplicating code and also keep it out of the viewController, MVC, I created a Class and called it "Strorage". With MVC does it really matter if each VC has it's own Model? I am guessing no as long as it is separate from the VC?
Can I just create a Storage Class. Then write Methods in the Storage Class that would only do task that needs to access the in internal storage by writing or reading? Then I instantiate the object from within the different VC that need those Methods.
Is this kind of how other people are doing it too?
Code:
- (NSString *) getDataFilePath
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [path objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:@"selectedClientInfo.plist"];
}
A number of viewControllers would access this code. To save space, duplicating code and also keep it out of the viewController, MVC, I created a Class and called it "Strorage". With MVC does it really matter if each VC has it's own Model? I am guessing no as long as it is separate from the VC?
Can I just create a Storage Class. Then write Methods in the Storage Class that would only do task that needs to access the in internal storage by writing or reading? Then I instantiate the object from within the different VC that need those Methods.
Is this kind of how other people are doing it too?