Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

spick

macrumors member
Original poster
Aug 17, 2007
51
0
Hey guys I'm new to Mac programming and I kind of need to know which Mac programming language I need to learn to make a small application.

Basically what I want to do is make an application that can generate a random string of text with a click of a button. This string of text can be store in a database or typed out in the program file itself, it doesn't matter as long as I can pull it with a click of a button.

I have done this with visual basic, but since I'm doing this for a friend and he only has a Mac so yeah.

Thank you guys
 
Objective-C is what you want.

If you're doing the programming on a mac then download the SDK from the apple website (also included on the discs that came with your mac). Also check the stickies at the top of the Mac Programming sub-section.
 
Is this a one-time thing? or are you trying to use this project as a learning experience with the intent to progress onward after it's done?
 
This is for learning experience, I'll check objective C and see how it goes.

For JavaScript/HTML, is it possible to end up with 1 file as the finish project? Like I said this is for a friend so I don't want something that would end up overcomplicated for him.
 
There should be no problem having an HTML page with embedded JavaScript, so the "deliverable" is a single file.

Is the purpose to display a fixed "random" string, or a new random string each time the button is pressed?

-Lee
 
Okay basically this is what I want, a button to click and a text field to display the randomly selected string of text. The text strings are going to be fixed.

Did a little digging for javacript and it looks like I'm going to go with this since it's a small application.
 
Okay basically this is what I want, a button to click and a text field to display the randomly selected string of text. The text strings are going to be fixed.

You should start with an Objective-C command-line tool to run from the terminal first just to get a feel for the logic. After you get that going it should be pretty easy to wire up your code to a NSButton and a NSTextField in Interface Builder (the app for making native GUI's on the Mac). If you search around the forum you'll find plenty of links to tutorials for learning Objective-C and Cocoa.
 
spick,

Is your intent to simply provide a solution for your friend or is it also your desire to learn to program Mac applications?

Ether way I took 30 minutes and threw together a hybrid ObjC/C++ solution. If you're interested I can post it.
 
My primary purpose is to provide something for my friend, but also want to learn on the way. I already started something with Javascript, but it's not perfect. So if you got something for me then yeah I would love to have it. I can use it for comparison and as an example. I'll pm you my email.
 
If you already have Visual Basic experience, you --might-- like REALbasic. REALbasic can also target Linux and Windows.

If writing for the Mac is all that you ever want to do, use Apple's native language Objective-C. However, if you're not religious about the Mac and want to learn something that's also useful outside the Apple microcosm, then do NOT go down the Objective-C alley.
 
My primary purpose is to provide something for my friend, but also want to learn on the way. I already started something with Javascript, but it's not perfect. So if you got something for me then yeah I would love to have it. I can use it for comparison and as an example. I'll pm you my email.

Well I've attached the Xcode project folder for anyone else that maybe interested.

It a very simple Application, started from an Xcode "Cocoa Application" template, called "RandomStringPresenter".

Added the code for your purposes to the default "RandomStringPresenterAppDelegate.h" and "RandomStringPresenterAppDelegate.m" files.

Renamed "RandomStringPresenterAppDelegate.m" to "RandomStringPresenterAppDelegate.mm" in order to compile it as ObjC++.

Added the text file "Spick Quotes.txt" to the Xcode project file such that it gets copied to the resulting applications embedded "Resources" folder. This is the file that contains the text that is to be displayed when the "Speak" button is pressed.

3 GUI elements were added to the file "MainMenu.xib" using "Interface Builder". A static text label, an editable text field (to receive and display the message) and button that when pressed will cause a random line of text to be pulled form the embedded "Spick Quotes.txt" file and displayed in the editable text field.

Enjoy


http://att.macrumors.com/attachment.php?attachmentid=207456&stc=1&d=1260983342
 

Attachments

  • RandomStringPresenter.zip
    21.7 KB · Views: 123
If you already know how to program in Basic, there are several free Basic interpreters for MacOS (Google them).

Simple Basic might be fine for your purposes, but no longer currently recommended for anything much over several dozen lines of code.

For something more future-proof, I would make a small Javascript/HTML page.

Objective C might be overkill, unless you plan on reusing your code or extending it to a much larger app for the Mac or iPhone, or need a Cocoa UI.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.