#include /* MakeParadigm * This tool should help you generate card stack files * containing a pattern of konjugation. The paradigm.plist file * contains some examples in latin, but feel free to contribute more. i * have no idea how well suited this is to other languages, put the algorithm * is plobably rather inflexible. * * usage: * MakeParadigm -paradigm "" -language "" -stem "" * * output goes to .plist */ int main(int argc, char** argv, char** env) { NSMutableDictionary *Paradigms, *Output; NSString *str, *language, *paradigm, *stem, *infinitive, *FirstValue, *SecondValue; NSEnumerator *enumerator; CREATE_AUTORELEASE_POOL(pool); Paradigms = [NSMutableDictionary dictionaryWithContentsOfFile: @"paradigms.plist"]; // [Paradigms setObject: @"some data" forKey: @"la"]; [NSProcessInfo initializeWithArguments:argv count:argc environment:env]; // NSLog(@"%@", [NSUserDefaults standardUserDefaults]); language = [[NSUserDefaults standardUserDefaults] stringForKey: @"language"]; paradigm = [[NSUserDefaults standardUserDefaults] stringForKey: @"paradigm"]; stem = [[NSUserDefaults standardUserDefaults] stringForKey: @"stem"]; if (language == nil || paradigm == nil || stem == nil) { NSLog(@"-language, -paradigm, or -stem missing.\n"); //NSLog(language); //NSLog(paradigm); //NSLog(stem); } //NSLog(@"%@\n", [[Paradigms objectForKey: language] objectForKey: paradigm]); infinitive = [[[Paradigms objectForKey: language] objectForKey: paradigm] objectForKey: @"infinitive"]; enumerator = [[[Paradigms objectForKey: language] objectForKey: paradigm] keyEnumerator]; id key; Output = [NSMutableDictionary new]; [Output setObject: [NSDictionary dictionaryWithObjectsAndKeys: @"", @"FirstValue" , language, @"SecondValue", nil ] forKey: @"Languages" ]; [Output setObject: @"" forKey: @"Notes"]; [Output setObject: [NSMutableArray new] forKey: @"Words"]; while ((key = [enumerator nextObject])) { NSLog(@"%@%@ %@ -- %@%@\n", stem, infinitive, key, stem, [[[Paradigms objectForKey: language] objectForKey: paradigm] objectForKey: key]); FirstValue = [NSString stringWithFormat: @"%@%@ %@", stem, infinitive, key ]; //NSLog(@"%@", FirstValue); SecondValue = [NSString stringWithFormat: @"%@%@", stem, [ [ [Paradigms objectForKey: language ] objectForKey: paradigm ] objectForKey: key ]]; //NSLog(@"%@", SecondValue); [[Output objectForKey: @"Words"] addObject: [NSDictionary dictionaryWithObjectsAndKeys: FirstValue, @"FirstValue", SecondValue, @"SecondValue", nil ]]; } //NSLog(@"%@\n", Output); [Output writeToFile: [NSString stringWithFormat: @"%@%@.cstack", stem, [ [ [Paradigms objectForKey: language ] objectForKey: paradigm ] objectForKey: @"infinitive" ] ] atomically: YES ]; RELEASE(pool); return 0; }