Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / February 2005



Tip: Looking for answers? Try searching our database.

Help initializing NSArray

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CyberSpiff - 23 Feb 2005 14:25 GMT
First, let me apologize my rookie questions, but I am a rank beginner at
Macintosh coding. I'e got quite a few years of C coding experience, but
never attempted Java or anything object-oriented. I'm laid-up after
surgery and to amuse myself and learn I'm trying to write a simple Mac
app using Cocoa and Java. I've started with searching the net and new
groups, but in this case I haven't found a clear-cut example.

What I want to do is pre-load a pull-down menu with entries to allow
entering of dates and times. I've got the pull-downs setup in IB, but
can't figure out how to load the text values into them. For example, the
month pull-down should contain something like "Jan" in the top entry,
followed by "Feb", etc. Days should be "1", then "2", etc.

What I'm stuck at is finding a clear example of initializing the
pull-downs. It seems like an NSArray would do the trick, but I may be
missing the boat entirely. If someone has been through this can could
provide some direction, it would be greatly appreciated.

Thanks in advance...

Signature

-spiff
Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself.

David Phillip Oster - 23 Feb 2005 17:18 GMT
> What I'm stuck at is finding a clear example of initializing the
> pull-downs. It seems like an NSArray would do the trick, but I may be
> missing the boat entirely. If someone has been through this can could
> provide some direction, it would be greatly appreciated.

Do a google search for:

cocoa bindings controller popup sample code

and see what you get.

Signature

David Phillip Oster

matt neuburg - 23 Feb 2005 17:25 GMT
> What I want to do is pre-load a pull-down menu with entries to allow
> entering of dates and times. I've got the pull-downs setup in IB, but
> can't figure out how to load the text values into them. For example, the
> month pull-down should contain something like "Jan" in the top entry,
> followed by "Feb", etc. Days should be "1", then "2", etc.

You should read the manual on NSMenuItem, NSMenu, and (if this is a
popup button) NSPopUpButton, and look at the MenuMadness example code
that is already on your hard disk. m.

Signature

matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
AppleScript: The Definitive Guide
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Read TidBITS! It's free and smart. http://www.tidbits.com

Patrick Machielse - 23 Feb 2005 17:49 GMT
> First, let me apologize my rookie questions, but I am a rank beginner at
> Macintosh coding. I'e got quite a few years of C coding experience, but
> never attempted Java or anything object-oriented. I'm laid-up after
> surgery and to amuse myself and learn I'm trying to write a simple Mac
> app using Cocoa and Java. I've started with searching the net and new
> groups, but in this case I haven't found a clear-cut example.

question: why not jump straight into Obj-C? There is much (much) more
documentation on Cocoa-ObjC than there exists on Cocoa-Java.

> What I want to do is pre-load a pull-down menu with entries to allow
> entering of dates and times. I've got the pull-downs setup in IB, but
> can't figure out how to load the text values into them. For example, the
> month pull-down should contain something like "Jan" in the top entry,
> followed by "Feb", etc. Days should be "1", then "2", etc.

1) Populate the month popup in IB. The # of months (probably) won't
  change.
2) Populate the days popup by code. A strategy would be to populate the
  days popup each time the selection in the month popup changes.

> What I'm stuck at is finding a clear example of initializing the
> pull-downs. It seems like an NSArray would do the trick, but I may be
> missing the boat entirely. If someone has been through this can could
> provide some direction, it would be greatly appreciated.

I don't use Cocoa Java, but it could be as simple as:

dayPopUp.removeAllItems();
dayPopUp.addItemsWithTitles(new NSArray(new String[]{"1", "2", "3"}));

where dayPopUp is the popup menu you made in IB.

As you can see it is a good idea to get to grips with creating and
manipulating objects before diving headlong into Cocoa. If you only know
C now, the fastest way to learn Cocoa would be to use the Apple Obj-C
tutorials (the infamous temperature converter...)

Good luck and get well soon...

patrick
CyberSpiff - 23 Feb 2005 18:03 GMT
[much good advice snipped]

Thank you all, David, Matt and Patrick. You're advice is excellent.
Thanks to you all (and Rhino from c.i.j.p in case you read this group
:-) ) I'm finally able to control the simple interface I have and am
ready to move onto more difficult (for me) things like file I/O and date
manipulation.

Signature

-spiff
Never be bullied into silence. Never allow yourself to be made a victim.
Accept no one's definition of your life; define yourself.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.