These changes let you write methods for KVO accessing using natural
Ruby syntax:
class T
kvo_array :squares do
def size
10
end
def [](i)
i * i
end
end
end
>> T.new.valueForKey('squares')
=> [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
---
lib/hotcocoa.rb |1 +
lib/hot
We had arrays, now let's have sets, too. Refactored out the base
redefinition code to make the set case easy to add.
---
lib/hotcocoa/kvo_accessors.rb | 39 ++
+
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/lib/hotcocoa/kvo_accessors.r
So, which is it, guys? A glorified macro pre-processor with enough
canned macros to illustrate how to use the same approach in your own
applications, or an attempt to simplify Cocoa programming where it
genuinely cries out for simplification, hopefully also in cases
which are commonly used
PS: Credits to Laurent who has been making an effort on writing more
and more tests for
the core part of MacRuby! :)
Ditto. I should say that the RubySpec effort is also useful for
testing MacRuby, in as much as it provides coverage for the vast
majority of the behavior which MacRuby share
Sure seems like a bug to me. Any ideas?
Sounds like it’s related to ticket #164. I’ll be looking into it Real
Soon Now™.
-Ben
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby
I'm pretty new to Cocoa, so maybe I'm overlooking the obvious here.
I just want to make sure I'm not doing more work than necessary.
I'd like to be able to control the minimum size for a NSSplitView.
As I understand it, I need to have a delegate with a method that can
handle
splitView:co
I am sure there is an easy answer to this question, but I have not
figured it out after some experimenting (nor can I find an example
in the examples)
What do I do if i want to subclass (say) an NSView ? And yet still
employ that subclass with all the rest of the hot cocoa magic? (so
with
I subclassed a Core Data entity Recipe with PPRecipe < NSManaged
object, and created accessors for the fields:
class PPRecipe < NSManagedObject
attr_accessor :name, :desc, :type, :imagePath, :serves
end
but these fields now don't save or display correct after I create
objects, and restart the a
In practice, you should avoid passing objects as context to methods
like this one, because their implementation won't keep a GC
reference to them, so they might disappear during a collection cycle.
Since the Cocoa frameworks are GC-aware, these are generally strong
pointers.
-Ben
I describe calling ruby side objects from the ObjC side. I can make
it work using dynamic classes but of course that generates compiler
warnings (like no '-baz' method found). Of course it still works,
but is there any way for my ObjC classes to know at compile time
what are the class name
That being said, it’d be nice if the runtime could dump a header
for the current state of a class, ScriptingBridge-style. I might
look into this.
That would be awesome. Something like sdef/sdp for Ruby classes
maybe those tools would be useful already.
Would be trivial to implement, maybe
Is there a way to access instance variables defined in an
Objective-C
class from a Ruby extension?
It is currently not implemented, but it's technically possible. A
good work-around is to define accessors (properties) as John
mentioned.
Maybe we need MacRuby::Runtime to bubble up the Obj
Here is the blurb:
http://www.macruby.org/project.html
I should say that I’m not a very frequent contributor, so you can
subtract one from the #size of that list.
-Ben
___
MacRuby-devel mailing list
[email protected]
http://lists.m
So plan B: We emulate Ruby 1.9 strings behavior on top of of
NSString/NSData.
I'm really interested in this discussion too. A little background
for JRuby:
Thanks for the background, Charlie. This sort of history is very
instructive.
* Java's strings are all UTF-16. In order to represent
When doing force_encoding, convert to a ByteString in the old
encoding, then try to convert to an NSString in the new encoding.
If we succeed, great. If not, leave as a tagged ByteString (and
probably whine about it).
That's actually wrong. All force_encoding does is change the
encoding a
Question, I would like to know if there is a "cocoa like" of the
GtkTable widget
http://pygtk.org/pygtk2tutorial/sec-PackingUsingTables.html
NSMatrix, sort of.
To quote every other post on cocoa-dev: what are you trying to do?
-Ben___
MacRuby-deve
Sorry, thank you for your help
I’m not sure if I was able to help!
When I asked “what are you trying to do,” I meant: “what does the UI
you are trying to create look like?” NSMatrix is only appropriate for
certain, very limited interfaces. Otherwise you’ll need to roll your
own, or play i
Thanks for the reply Laurent. Yes I did generate a BridgeSupport file
and included it in my build. I did try to call the method and pass in
a pointer for the item reference (using Pointer.new_for_type('@')) but
the object that was assigned after the call was some weird NSCFType
object which, whe
Coming from a Ruby background, I try to understand and pick the
best from Obj-C/Cococa and learn how to use brilliant ideas to
improve my coding.
Tonight I was working on a simple demo app to learn how things are
done in the Obj-C world and see how they would transpose to the
MacRuby wor
This is currently not implemented. It is not planned for the
upcoming release mostly because I don't think it's that important,
since all block methods in Cocoa also have methods dealing with
function pointers, which will be supported.
Not true of some of the new Foundation and AppKit APIs.
def insertObject(p, inEmployeesAtIndex:index)
NSLog("adding #{p} to #{employees}") # <= Not called, huh?
undo = @undoManager
undo.prepareWithInvocationTarget(self,
removeObjectFromEmployeesAtIndex:index)
if !undo.isUndoing
undo.setActionName("Insert Person")
end
21 matches
Mail list logo