[MacRuby-devel] MacRuby-devel Digest, Vol 22, Issue 62

Matt Aimonetti mattaimonetti at gmail.com
Wed Dec 30 10:09:54 PST 2009


Hi Martin,

 You are bringing a good point. One can certainly write Cocoa apps without
Xcode, it's far from a requirement.

I used to have a small section in the book that was showing you how to
create a UI with Interface Builder, load the Address People Picker view
widget, simulate the UI and save it as a nib called 'picker.nib' (xib files
have to be compiled).

You can then open vim, textmate or whatever editor you fancy, and type the
following code:

framework 'Cocoa'
framework 'AddressBook'

app = NSApplication.sharedApplication
controller =
NSWindowController.alloc.initWithWindowNibPath(File.expand_path('picker.nib'),
owner:self)
controller.window
app.run

Save the file in the same directly than your nib file and launch the script:

$ macruby picker.rb
(you can also compile the file using macrubyc)

You will notice that the UI launches and seems to work fine until you try to
type some text in the text input box. (the text will show in the terminal
and not the UI)
Really, what you want is to create a .app and everything will be fine, but
doing that manually isn't really straight forward.
Also, having to bind UI elements with classes, actions and outlet is a pain
if you don't use Xcode.

At the end of the day, or we have something like HotCocoa/Rucola which works
fine and can be an alternative to Xcode, or every time you will want to
write a Cocoa app, you will rely on Xcode.

I still hope that Rich and Eloy will be able to finish their tools on time
so I can have a section on Xcode alternatives, but to start with, I think
it's better to show the "standard" way to write Cocoa apps in MacRuby, and
that means using Xcode.
I'm also planning on having a section on apps without an UI and for that, we
won't need Xcode.

I hope that makes sense, thanks for your feedback.

- Matt



On Wed, Dec 30, 2009 at 12:40 PM, Martin Kay <mjkay at stanford.edu> wrote:

> I look forward to your book with impatience.  From the other stuff I have
> seen of yours, I expect that it will be both informative and literate.
>
> May I put in a plea, hopefully before it is too late? Could you please
> either make mastery of xcode optional---which I would prefer---or provide a
> mental model for it that makes it coherent?  Every purported introduction
> attempts to lead me by the hand through a morass of totally unmotivated
> complexity while expecting me to be grateful for how it is simplifying my
> life.  It would be a great pity if the elegance of Macruby could only be
> appreciated after hacking ones way through miles of xcode underbrush.
>
> --Martin Kay
>
> On Dec 29, 2009, at 10:46 PM, macruby-devel-request at lists.macosforge.orgwrote:
>
> > Send MacRuby-devel mailing list submissions to
> >       macruby-devel at lists.macosforge.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >       http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> > or, via email, send a message with subject or body 'help' to
> >       macruby-devel-request at lists.macosforge.org
> >
> > You can reach the person managing the list at
> >       macruby-devel-owner at lists.macosforge.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of MacRuby-devel digest..."
> >
> >
> > Today's Topics:
> >
> >   1. Error Handling (Robert Rice)
> >   2. Input field list (Robert Rice)
> >   3. Re: Input field list (Steven Canfield)
> >   4. Re: Input field list (Matt Aimonetti)
> >   5. detect the language of a string (Matt Aimonetti)
> >   6. Re: detect the language of a string (Conrad Taylor)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Tue, 29 Dec 2009 20:42:00 -0500
> > From: Robert Rice <rice.audio at pobox.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: [MacRuby-devel] Error Handling
> > Message-ID: <22ADDFA8-03F6-4136-993C-26D3D7F47C80 at pobox.com>
> > Content-Type: text/plain; charset="us-ascii"
> >
> > MacRuby is working out well for my application with the exception of
> error handling. I find that I cannot get a traceback of all errors even when
> I have a rescue pushed on the stack. Sending a message to an undefined class
> action causes a hang with no error message that I cannot recover from. Nor
> can I always get useful information from the "bt" command in GDB if GDB even
> remains running after the error.
> >
> > Is there a way to trace actions calls from NSApplicationMain?
> >
> > Thanks,
> > Bob Rice
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091229/570d90dd/attachment-0001.html
> >
> >
> > ------------------------------
> >
> > Message: 2
> > Date: Wed, 30 Dec 2009 00:01:33 -0500
> > From: Robert Rice <rice.audio at pobox.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: [MacRuby-devel] Input field list
> > Message-ID: <DF3450DA-DEB9-4146-9164-FEEDF2C719EE at pobox.com>
> > Content-Type: text/plain; charset=us-ascii
> >
> > This is an unrelated Cocoa newbe question but I'm sure someone could help
> me.
> >
> > Is there a way to programmatically get a list of the input and control
> field objects in a view rather than linking all of the fields separately in
> Interface Builder?
> >
> > Thanks,
> > Bob Rice
> >
> >
> >
> > ------------------------------
> >
> > Message: 3
> > Date: Tue, 29 Dec 2009 22:51:19 -0700
> > From: Steven Canfield <stevencanfield.macruby at gmail.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Cc: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: Re: [MacRuby-devel] Input field list
> > Message-ID: <8475E755-D3BF-436F-9D98-1E72F48E8F32 at gmail.com>
> > Content-Type: text/plain;     charset=us-ascii;       format=flowed;
>  delsp=yes
> >
> > Get the views subviews and iterate on them by class name. -
> > isKindOfClass is the method. You could write filter / utility methods
> > to make this easier.
> >
> > Steve Canfield
> >
> > On Dec 29, 2009, at 10:01 PM, Robert Rice <rice.audio at pobox.com> wrote:
> >
> >> This is an unrelated Cocoa newbe question but I'm sure someone could
> >> help me.
> >>
> >> Is there a way to programmatically get a list of the input and
> >> control field objects in a view rather than linking all of the
> >> fields separately in Interface Builder?
> >>
> >> Thanks,
> >> Bob Rice
> >>
> >> _______________________________________________
> >> MacRuby-devel mailing list
> >> MacRuby-devel at lists.macosforge.org
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >
> >
> > ------------------------------
> >
> > Message: 4
> > Date: Wed, 30 Dec 2009 01:08:47 -0500
> > From: Matt Aimonetti <mattaimonetti at gmail.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: Re: [MacRuby-devel] Input field list
> > Message-ID:
> >       <20fefa50912292208l737e788el5b25c26530fb07d3 at mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > note that Obj-C's isKindOfClass is the same as Ruby's #is_a?
> >
> > I would personally iterate on the subviews and use a switch case
> statement
> > to look at each item's class and act on them accordingly.
> >
> > - Matt
> >
> > On Wed, Dec 30, 2009 at 12:51 AM, Steven Canfield <
> > stevencanfield.macruby at gmail.com> wrote:
> >
> >> Get the views subviews and iterate on them by class name. -isKindOfClass
> is
> >> the method. You could write filter / utility methods to make this
> easier.
> >>
> >> Steve Canfield
> >>
> >>
> >> On Dec 29, 2009, at 10:01 PM, Robert Rice <rice.audio at pobox.com> wrote:
> >>
> >> This is an unrelated Cocoa newbe question but I'm sure someone could
> help
> >>> me.
> >>>
> >>> Is there a way to programmatically get a list of the input and control
> >>> field objects in a view rather than linking all of the fields
> separately in
> >>> Interface Builder?
> >>>
> >>> Thanks,
> >>> Bob Rice
> >>>
> >>> _______________________________________________
> >>> MacRuby-devel mailing list
> >>> MacRuby-devel at lists.macosforge.org
> >>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >>>
> >> _______________________________________________
> >> MacRuby-devel mailing list
> >> MacRuby-devel at lists.macosforge.org
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >>
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091230/0d0ef9c4/attachment-0001.html
> >
> >
> > ------------------------------
> >
> > Message: 5
> > Date: Wed, 30 Dec 2009 01:20:26 -0500
> > From: Matt Aimonetti <mattaimonetti at gmail.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: [MacRuby-devel] detect the language of a string
> > Message-ID:
> >       <20fefa50912292220r7bd28211veece8c6f84e0983a at mail.gmail.com>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Curious of seeing if I could use a Cocoa framework to detect the language
> of
> > a string, I ended up finding a surprisingly clean and easy solution.
> > I decided to post my findings online since I couldn't find anything when
> I
> > googled the topic:
> >
> > http://merbist.com/2009/12/29/fun-with-macruby/
> >
> > In less than 10LOC, here is how to implement this feature:
> >
> >
> > framework 'Foundation'
> > class String
> >
> >  def language
> >    CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0,
> self.size))
> >
> >  end
> > end
> >
> > "bonne ann?e!".language # => "fr"
> >
> > - Matt
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091230/d2366100/attachment-0001.html
> >
> >
> > ------------------------------
> >
> > Message: 6
> > Date: Tue, 29 Dec 2009 22:46:07 -0800
> > From: Conrad Taylor <conradwt at gmail.com>
> > To: "MacRuby development discussions."
> >       <macruby-devel at lists.macosforge.org>
> > Subject: Re: [MacRuby-devel] detect the language of a string
> > Message-ID:
> >       <7317d7610912292246i3127b84dgfae9c8b403491f85 at mail.gmail.com>
> > Content-Type: text/plain; charset="iso-8859-1"
> >
> > On Tue, Dec 29, 2009 at 10:20 PM, Matt Aimonetti <
> mattaimonetti at gmail.com>wrote:
> >
> >> Curious of seeing if I could use a Cocoa framework to detect the
> language
> >> of a string, I ended up finding a surprisingly clean and easy solution.
> >> I decided to post my findings online since I couldn't find anything when
> I
> >> googled the topic:
> >>
> >> http://merbist.com/2009/12/29/fun-with-macruby/
> >>
> >> In less than 10LOC, here is how to implement this feature:
> >>
> >> framework 'Foundation'
> >> class String
> >>
> >>
> >>  def language
> >>    CFStringTokenizerCopyBestStringLanguage(self, CFRangeMake(0,
> self.size))
> >>
> >>
> >>  end
> >> end
> >>
> >> "bonne ann?e!".language # => "fr"
> >>
> >> - Matt
> >>
> >>
> > Matt, this is very cool and thanks for the post.
> >
> > -Conrad
> >
> >
> >> _______________________________________________
> >> MacRuby-devel mailing list
> >> MacRuby-devel at lists.macosforge.org
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >>
> >>
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091229/28aa9d63/attachment.html
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > MacRuby-devel mailing list
> > MacRuby-devel at lists.macosforge.org
> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >
> >
> > End of MacRuby-devel Digest, Vol 22, Issue 62
> > *********************************************
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091230/57898a5a/attachment-0001.html>


More information about the MacRuby-devel mailing list