newbie dictionary/unicode problem
newbie dictionary/unicode problem
- Subject: newbie dictionary/unicode problem
- From: Daniel Child <email@hidden>
- Date: Fri, 04 Feb 2005 17:30:25 -1000
Hi all,
Thanks to all who explained not to place Unicode values into the source code, suggesting alternative strategies.
I am trying to make sense of a basic problem I have with dictionaries. I am trying to assign a set of unicode values to array, and then store those values in a dictionary. The problem is that I get a warning. Here is the code.
// SET UP FULL DICTIONARY OF BOPOMOFO CHARS
unichar bpmfArray[37];
NSString *bpmf[37];
NSMutableDictionary *fullBpmfDic = [NSMutableDictionary dictionary];
int i;
unichar unival = 0x3105; // the first character in bopomofo series
for (i = 0; i < 37; i++) {
bpmfArray[i] = unival;
bpmf[i] = [NSString stringWithCharacters: &bpmfArray[i] length:1];
[fullBpmfDic setObject: bpmf[i] forKey: unival];
NSLog(@"%C %C", bpmfArray[i], bpmf[i]);
unival++;
}
The warning I get is as follows:
main.m:39: warning: passing arg 2 of `setObject:forKey:' makes pointer from integer without a cast
It seems that I am supposed to use an object for the key, not just the dictionary object. But what type should I use? I got a complaint for NSNumber, and somehow 0x3105 does not strike me to be a "string."
More importantly, there must be a better way to go about this. Is there a simple way to put all Unicode values of a certain type into a dictionary? People have suggested I look into "localizer" but I am not "translating strings" but rather want to import large swathes of characters and associated data into files. Now, the data will probably be a flat comma-delimited file, so I am wondering how I can iimport that kind of thing into a dictionary. The dictionaryWithContentsOfFile seems to presume XML-formatted material, which I don't have. Any suggestions?
Thanks,
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden