• 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: questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: questions


  • Subject: Re: questions
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 13 Aug 2001 20:54:21 +0200

Farl,

sorry, I'm not that familiar with NSURLs. Otherwise:

>>>>>> Farl (F) wrote at Mon, 13 Aug 2001 11:30:23 -0700:
F> 2.
F> I want to build in a set of hash tables for key values. Namely the hash
F> set of error codes to error names (as in above). Now I think the way to do
F> this is using NSMutableDictionary.

Right.

F> experience, and the absolute stupidity of how Apple sets out its developer
F> docs, it lists the commands, but simply fails to give some simple examples
F> of how to actually use it in a real way. Any simple example code of this
F> would be great.

I guess there would be something in the Examples. But, you can go like

NSMutableDictionary *dict...;

// store pair 3333, "strange value"
[dict setObject:@"strange value" forKey:[NSNumber numberWithInt:3333]];
// get the value for key 3333
NSString *val=[dict objectForKey:[NSNumber numberWithInt:3333]];

Enough?

(Digression: if you want to be able to enter the values using something like

dict=[NSMutableDictionary dictionaryWithObjectsAndKeys:@"strange
code",@"3333",nil];

you can encode the numbers using [NSString stringWithFormat:@"%d",n]. It is
somewhat less efficient, but in your case the difference would be
negligible).

F> 3.
F> I want to load the set of hash tables (see above) when the program loads.
F> Normally in c++ i would just stick all of it in a procedure that ran first
F> under int main();. However, I cannot see where to do this in osX's cocoa
F> layout. I need these hash tables to load up when the program does, not
F> everytime the "go" button is pressed in my program.

See the NSApplication.html, especially the applicationDidFinishLaunching:
delegate message.

Another nice possibility is to check whether the variable was inited already:

if (!dict) dict=[[NSMutableDictionary alloc] initWithContentsOfFile:...];

F> 4.
F> And lastly, with NSString, is there a limit to how long a NSString can be?

There is not (but the address space / free disk space size ;)
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


References: 
 >questions (From: email@hidden (Farl))

  • Prev by Date: Re: EOF Advocacy
  • Next by Date: Checkboxes in NSTableView
  • Previous by thread: questions
  • Next by thread: Re: cocoa-dev digest, Vol 1 #388 - 15 msgs
  • Index(es):
    • Date
    • Thread