PDA

View Full Version : how to change function types




eagerterrier
Feb 5, 2009, 04:23 PM
I have a controller that I want to be in charge of getting and setting preferences in the plist files

And I have some code like this

Prefs *prefController = [[Prefs alloc] init];
NSString *cachingOn = [prefController getPreference:@"cachingOn"];

NSLog(@"The preference is *%@*",cachingOn);

if([cachingOn isEqual:@"on"]){
NSLog(@"Caching is on!");

}


Now this works fine. Just great. However, when I have plist nodes that are boolean or date etc, this code just doesn't cut it.

The problem is that my Prefs->getPreference method returns an NSString.

My question is, how do I get the method to return whatever data type the plist node is?

Thanks


TC



caveman_uk
Feb 6, 2009, 07:53 AM
What's wrong with the built in preferences system using NSUserDefaults? This would seem to do everything you want.

Anyway, in answer to your question is to make the return type id.