• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: newbie dictionary/unicode problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie dictionary/unicode problem


  • Subject: Re: newbie dictionary/unicode problem
  • From: Kevin Ballard <email@hidden>
  • Date: Sat, 5 Feb 2005 00:08:06 -0500

The warning is because your key is unival, which is a unichar, which is a C type, not an object pointer. An NSNumber should work as a key since NSMutableDictionary defines setObject:forKey: as taking an id for the key (although I've never used anything other than NSStrings). I'm not sure what you're trying to accomplish here - I didn't see any previous thread in which you may have discussed that. If you can clarify what you're trying to put in the dictionary, perhaps I can suggest an alternate method.

On Feb 4, 2005, at 10:30 PM, Daniel Child wrote:

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?

-- Kevin Ballard email@hidden http://www.tildesoft.com http://kevin.sb.org

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >newbie dictionary/unicode problem (From: Daniel Child <email@hidden>)

  • Prev by Date: newbie dictionary/unicode problem
  • Next by Date: NSCoding question regarding BOOL
  • Previous by thread: newbie dictionary/unicode problem
  • Next by thread: NSCoding question regarding BOOL
  • Index(es):
    • Date
    • Thread