After
I am parsing a list of locations and want to return a UIImage with a flag based on these locations .
I have a string with space, it can be several different places and I would like to find this string for potential matches in NSArray, and when a match occurs, then in an NSDictionary Must get the proper file name.
Here is an example of NSDRA and NSArray:
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys: @ "franceFlag", @ "France", @ "greeceFlag", @ "Greece", @ "spainFlag", @ "Spain", @ "norway flag", @ "norway", nil]; NSArray * array = [NSArray arrayWithObjects: @ "France" @ "Greece" @ "Spain" @ "Portugal" @ "Ireland" @ "Norway", zero];
Obviously I will have a lot of countries and flags in both of them.
Even what I have so far:
- (UIImage *) Flag from the Ground: (NSString *) locationString {NSRange range; (Arraystring in NSString * countryArray) for {range = [locationString lowercase string] rangeOfString: arrayString]; If (range.location = NSNotFound!) {Return [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: [Dictionary objectForKey: arrayString] ofType: @ "png"]]; }} Return zero; }
Now, the above does not really work. I am missing something (and maybe even the first place is not correct) The point is, in many places of the same country in the location string, "Barcelona, Spain", "Madrid, Spain", "Northern Spain ", etc., but I want to retrieve" Spain "in this case. (Also, notifications of Caps for each country).
Actually, I want to search for the location. String I pass through the countries listed in NSARE with one of the method for any potential mail. If / when no one is found, then it should remain in the NSDictionary and get the appropriate flag based on the correct matching string from the array. I believe the best method is to pick the string from the array, as it will be a stripped version of the place.
Any help to point me in the right direction for the last bit is enough. Appreciate
Here I found myself (also edited to the right above): < / P>
- (UIImage *) flagformogin: (NSString *) locationString {NSR range; (Arraystring in NSString * countryArray) for {range = [locationString lowercase string] rangeOfString: arrayString]; If (range.location = NSNotFound!) {Return [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: [Dictionary objectForKey: arrayString] ofType: @ "png"]]; }} Return zero; }
Comments
Post a Comment