Reputation: 93
I want create an iOS app for my school. This App will show Week schledule and when I tap on Cell with Subject, it will show me detail info about subject...
My problem: Our teachers use shotcuts for their names, but I want show their full name... I created the file "ucitele.h" with definitions of their names, but I don't know, how to use it 😕.
This is how that file looks:
//
// ucitele.h
//
#define Li @"RNDr. Dan---vá"
#define He @"Mgr. Ja---hl"
#define Sm @"Ing. Mich---rek"
#define Ks @"Mgr. Svat---á"
I get the shortcut of Teacher from previous view from "self.ucitel" and I maybe want compare the contents of the "self.ucitel" with definitions and set the "ucitelFull" string from the definitions? I don't know how to say it 😕.
when the content of the self.ucitel will be @"Sm", than I want parse "ucitelFull" as @"Ing. Mich---rek"
Answers in Objective-C only please
Upvotes: 1
Views: 52
Reputation: 8001
Okay, sounds like your trying to map a short identifier to a full name:
-(NSString*)fullNameFromShortName:(NSString*)short {
NSDictionary * names = @{@"Li" : @"RNDr. Dan---vá",
@"He" : @"Mgr. Ja---hl", ... };
return [names objectForKey:short];
}
Use like:
self.ucitelFull = [self fullNameFromShortName:self.ucitel];
This is a dictionary that has the short name as a key and the full name as the value.
Some further suggestions:
lowercaseString
's, incase the user doesn't enter the value with the correct case. Upvotes: 2