Re: [MacRuby-devel] MacRuby class inside obj-c
And by trying a bit I see blocks are not supported,
am I right?
2010/5/18 Laurent Sansonetti
> Indeed, methods with normal arities (0..n arguments) conform to the
> Objective-C ABI, so using the bracket syntax just works. But for Ruby
> methods using complex arities (like splat or optional arguments), you will
> likely get a crash. This is why the -performRubySelector: method was
> introduced. It is better to always use that method, because it always works
> (in theory).
>
> Laurent
>
>
> On May 18, 2010, at 3:05 PM, Louis-Philippe wrote:
>
> great!
> I can even seem to send messages directly to my MacRuby classes and
> instances...
> like:
> id obj = [Foo new:@"objc"];
> and
> [obj hello];
>
> but in the second case I get a compiler warning: "No -hello method found"??
>
> 2010/5/18 Laurent Sansonetti
>
>> Hi Louis-Philippe,
>>
>> Assuming MacRuby code defines:
>>
>> class Foo
>> def initialize(message)
>>@message
>> end
>> def hello
>>puts "hello #{message}"
>> end
>> end
>>
>> You should be able to retrieve a reference to Foo using:
>>
>> Class Foo = [[MacRuby sharedRuntime] evaluateString:@"Foo"];
>>
>> Or, more simply:
>>
>> Class foo = NSClassFromString(@"Foo");
>>
>> You might want to use the first way in case the class has a complex path
>> (if it's defined inside modules, like "Foo::Bar").
>>
>> Later, you can send messages to it.
>>
>> id obj = [Foo performRubySelector:@selector(new:) withArguments: @"objc",
>> nil];
>> [obj performRubySelector:@selector(hello)];
>>
>> Laurent
>>
>> On May 18, 2010, at 2:31 PM, Louis-Philippe wrote:
>>
>> > Hi,
>> > I don't know if this is the good list to ask this question as it is my
>> first...
>> > So,
>> >
>> > I saw how I can have a MacRuby cocoa app, importing objective-c classes.
>> > I can't find info on how to do the opposite... having an Objective-C
>> cocoa app, importing and using MacRuby Classes...
>> >
>> > All I managed to do is to "evaluateFileAtPath:" and "evaluateString:"
>> >
>> > Thanks!
>> >
>> > L-P
>> > ___
>> > MacRuby-devel mailing list
>> > [email protected]
>> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] NSLocaliszed* functions missing
With macruby 0.6 when I try and use NSLocalizedStringFromTable I get the
following:
~> macirb
irb(main):001:0> framework 'cocoa'
=> true
irb(main):002:0> NSLocalizedStringFromTable('', '', '')
NoMethodError: undefined method `NSLocalizedStringFromTable' for main:TopLevel
from /Users/dave/(irb):2:in `'
I believe NSLocalizedStringFromTable is part of the Foundation framework.
Also all the other NSLocalized* functions seem to be missing.
Dave.
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] NSLocaliszed* functions missing
Hi Dave,
NSLocalizedStringFromTable is a C macro defined in NSBundle.h that wraps a call
to localizedStringForKey:value:table:.
You can call the localize method directly by using something like:
NSBundle.mainBundle.localizedStringForKey('key', value:'value',
table:'table').
HTH,
Ed
On May 19, 2010, at 9:25 AM, Dave Baldwin wrote:
> With macruby 0.6 when I try and use NSLocalizedStringFromTable I get the
> following:
>
> ~> macirb
> irb(main):001:0> framework 'cocoa'
> => true
> irb(main):002:0> NSLocalizedStringFromTable('', '', '')
> NoMethodError: undefined method `NSLocalizedStringFromTable' for main:TopLevel
> from /Users/dave/(irb):2:in `'
>
> I believe NSLocalizedStringFromTable is part of the Foundation framework.
> Also all the other NSLocalized* functions seem to be missing.
>
> Dave.
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] MacRuby class inside obj-c
That is correct. Support for blocks in MacRuby is not implemented (yet). :-)
--
Thibault Martin-Lagardette
On May 19, 2010, at 05:37, Louis-Philippe wrote:
> And by trying a bit I see blocks are not supported,
> am I right?
>
> 2010/5/18 Laurent Sansonetti
> Indeed, methods with normal arities (0..n arguments) conform to the
> Objective-C ABI, so using the bracket syntax just works. But for Ruby methods
> using complex arities (like splat or optional arguments), you will likely get
> a crash. This is why the -performRubySelector: method was introduced. It is
> better to always use that method, because it always works (in theory).
>
> Laurent
>
>
> On May 18, 2010, at 3:05 PM, Louis-Philippe wrote:
>
>> great!
>> I can even seem to send messages directly to my MacRuby classes and
>> instances...
>> like:
>> id obj = [Foo new:@"objc"];
>> and
>> [obj hello];
>>
>> but in the second case I get a compiler warning: "No -hello method found"??
>>
>> 2010/5/18 Laurent Sansonetti
>> Hi Louis-Philippe,
>>
>> Assuming MacRuby code defines:
>>
>> class Foo
>> def initialize(message)
>>@message
>> end
>> def hello
>>puts "hello #{message}"
>> end
>> end
>>
>> You should be able to retrieve a reference to Foo using:
>>
>> Class Foo = [[MacRuby sharedRuntime] evaluateString:@"Foo"];
>>
>> Or, more simply:
>>
>> Class foo = NSClassFromString(@"Foo");
>>
>> You might want to use the first way in case the class has a complex path (if
>> it's defined inside modules, like "Foo::Bar").
>>
>> Later, you can send messages to it.
>>
>> id obj = [Foo performRubySelector:@selector(new:) withArguments: @"objc",
>> nil];
>> [obj performRubySelector:@selector(hello)];
>>
>> Laurent
>>
>> On May 18, 2010, at 2:31 PM, Louis-Philippe wrote:
>>
>> > Hi,
>> > I don't know if this is the good list to ask this question as it is my
>> > first...
>> > So,
>> >
>> > I saw how I can have a MacRuby cocoa app, importing objective-c classes.
>> > I can't find info on how to do the opposite... having an Objective-C
>> > cocoa app, importing and using MacRuby Classes...
>> >
>> > All I managed to do is to "evaluateFileAtPath:" and "evaluateString:"
>> >
>> > Thanks!
>> >
>> > L-P
>> > ___
>> > MacRuby-devel mailing list
>> > [email protected]
>> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] CSV still buggy
Hi,
I saw:
Ticket #125 (closed defect: fixed)
about CSV.
I do a pretty simple test:
###
require 'csv'
CSV.open('testCSV.csv', 'r') do |row|
p row
end
###
this test works in ruby 1.8.7, but in macruby 0.6 I get an empty reader...
my arch is: MacRuby version 0.6 (ruby 1.9.0) [universal-darwin10.0, x86_64]
thanks!
L-P
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] [MacRuby] #723: nsset + bindings error
#723: nsset + bindings error
---+
Reporter: jakub.su...@… | Owner: lsansone...@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby|Keywords:
---+
I have a weird error related to NSSet.setWithObjects method and bindings.
I'm not sure exactly what causes it, but my guess is that it's some kind
of problem with methods that accept variable number of arguments, that
only appears in some specific conditions. It took me a few hours to
isolate only the relevant code, but I managed to cut it down to two small
classes where changing anything else makes the error disappear (see
attached zip with a project).
So I have a model class with 3 fields and 2 helper methods using those
fields. For those 2 helper methods, I provide KVO methods
keyPathsForValuesAffecting*** returning sets. In the app delegate, I
create one instance of that class and 2 views, and bind two properties of
the views to the methods in the model object.
When I get to NSSet.setWithObjects("sender", "recipient", nil) in
keyPathsForValuesAffectingSenderAndRecipient, the application hangs.
Now, if I change anything in this code, it stops hanging; for example:
- if I use NSSet.setWithArray(["sender", "recipient"]), it works
- if I use a set with just "sender" (NSSet.setWithObjects("sender", nil)),
it works
- if I delete the second KVO method
(keyPathsForValuesAffectingHasPicture), the first one starts working
- if I don't bind the first view to keyPathsForValuesAffectingHasPicture,
or change the order of bindings, it starts working
- if I return a 2-element set in keyPathsForValuesAffectingHasPicture, it
starts working (?!)
- and here's the funniest one: if I copy the line
NSSet.setWithObjects("sender", "recipient", nil) to application delegate,
before the bindings, it works there, and the original invocation inside
keyPathsForValuesAffectingSenderAndRecipient also magically starts working
(?!?!)
As you can see, it's hard to figure out what's going on here... But as far
as I can tell, this smells to me like some kind of bug related to memory,
pointers pointing to wrong places and so on... (oh, good old C times... :)
And BTW, if I rewrite the model class (Message) in ObjC, it also starts
working.
Tested on MacRuby 0.6.
--
Ticket URL:
MacRuby
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
