[MacRuby-devel] How to use NSIndexSet with tableView data
Hi ! I'm trying to use a tableView with MacRuby. What I want to do is remove items from my data array based on the tableView selection. I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and I don't know how to use it with my array. Can you give me some leads on the subject ? Thanks, ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
Since an Array is a NSArray: http://bit.ly/de3kxd, maybe something like the following? $ macirb irb(main):001:0> a = ['apple', 'tuna', 'orange'] => ["apple", "tuna", "orange"] irb(main):002:0> indices = NSIndexSet.indexSetWithIndex(1) => # irb(main):003:0> fish = a.objectsAtIndexes(indices) => ["tuna"] Eloy On Sat, Oct 23, 2010 at 1:18 PM, Pixoo wrote: > Hi ! > > I'm trying to use a tableView with MacRuby. > What I want to do is remove items from my data array based on the tableView > selection. > > I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and I > don't know how to use it with my array. > Can you give me some leads on the subject ? > > Thanks, > > ___ > 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] How to use NSIndexSet with tableView data
That doesn't match what I need. Ok, here is what I have : My data is the @items variable which is an array of objects. My tableView is @tableView. The action is a reaction to a click on a remove button after a selection in the table. What I want to do is something like this : def removeItems(sender) indexes = @tableView.selectedRowsIndexes @items.delete_at(indexes) @tableView.reloadData end But I can't get a way to make it work. On Sat, Oct 23, 2010 at 2:03 PM, Eloy Duran wrote: > Since an Array is a NSArray: http://bit.ly/de3kxd, maybe something > like the following? > > $ macirb > irb(main):001:0> a = ['apple', 'tuna', 'orange'] > => ["apple", "tuna", "orange"] > irb(main):002:0> indices = NSIndexSet.indexSetWithIndex(1) > => # > irb(main):003:0> fish = a.objectsAtIndexes(indices) > => ["tuna"] > > Eloy > > On Sat, Oct 23, 2010 at 1:18 PM, Pixoo wrote: > > Hi ! > > > > I'm trying to use a tableView with MacRuby. > > What I want to do is remove items from my data array based on the > tableView > > selection. > > > > I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and I > > don't know how to use it with my array. > > Can you give me some leads on the subject ? > > > > Thanks, > > > > ___ > > 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
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
As always, the docs are your friend. Look up the enumeration methods in http://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Classes/NSIndexSet_Class/Reference/Reference.html -- Alistair Holt On 23 Oct 2010, at 13:14, Pixoo wrote: > NSIndexSet ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
I already looked at those functions but I couldn't believe there was no way to obtain a simple array of the indexes list. I seams that's the case... Thanks, On Sat, Oct 23, 2010 at 2:31 PM, Alistair Holt wrote: > As always, the docs are your friend. Look up the enumeration methods in > > http://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Classes/NSIndexSet_Class/Reference/Reference.html > > -- > Alistair Holt > > > On 23 Oct 2010, at 13:14, Pixoo wrote: > > > NSIndexSet > ___ > 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] How to use NSIndexSet with tableView data
You’re right, I forgot to include the line that basically did: @items -= fish. However, since an array is actually of the mutable type NSMutableArray, you can use its API as well http://bit.ly/90436W. irb(main):007:0> a.removeObjectsAtIndexes(indices) => ["apple", "orange"] If you find you need to work with NSIndexSet's a lot, you could go to town and add this to NSIndexSet: http://gist.github.com/642166 HTH, Eloy On Sat, Oct 23, 2010 at 2:14 PM, Pixoo wrote: > That doesn't match what I need. > Ok, here is what I have : > > My data is the @items variable which is an array of objects. > My tableView is @tableView. > The action is a reaction to a click on a remove button after a selection in > the table. > > What I want to do is something like this : > > def removeItems(sender) > indexes = @tableView.selectedRowsIndexes > @items.delete_at(indexes) > @tableView.reloadData > end > > But I can't get a way to make it work. > > On Sat, Oct 23, 2010 at 2:03 PM, Eloy Duran wrote: >> >> Since an Array is a NSArray: http://bit.ly/de3kxd, maybe something >> like the following? >> >> $ macirb >> irb(main):001:0> a = ['apple', 'tuna', 'orange'] >> => ["apple", "tuna", "orange"] >> irb(main):002:0> indices = NSIndexSet.indexSetWithIndex(1) >> => # >> irb(main):003:0> fish = a.objectsAtIndexes(indices) >> => ["tuna"] >> >> Eloy >> >> On Sat, Oct 23, 2010 at 1:18 PM, Pixoo wrote: >> > Hi ! >> > >> > I'm trying to use a tableView with MacRuby. >> > What I want to do is remove items from my data array based on the >> > tableView >> > selection. >> > >> > I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and I >> > don't know how to use it with my array. >> > Can you give me some leads on the subject ? >> > >> > Thanks, >> > >> > ___ >> > 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
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
Ok it worked \o/ I'm pretty new at ObjC (therefore I use MacRuby :D) so I don't know NS objects. Thanks again :) On Sat, Oct 23, 2010 at 2:43 PM, Eloy Duran wrote: > You’re right, I forgot to include the line that basically did: @items > -= fish. However, since an array is actually of the mutable type > NSMutableArray, you can use its API as well http://bit.ly/90436W. > > irb(main):007:0> a.removeObjectsAtIndexes(indices) > => ["apple", "orange"] > > If you find you need to work with NSIndexSet's a lot, you could go to > town and add this to NSIndexSet: http://gist.github.com/642166 > > HTH, > Eloy > > On Sat, Oct 23, 2010 at 2:14 PM, Pixoo wrote: > > That doesn't match what I need. > > Ok, here is what I have : > > > > My data is the @items variable which is an array of objects. > > My tableView is @tableView. > > The action is a reaction to a click on a remove button after a selection > in > > the table. > > > > What I want to do is something like this : > > > > def removeItems(sender) > > indexes = @tableView.selectedRowsIndexes > > @items.delete_at(indexes) > > @tableView.reloadData > > end > > > > But I can't get a way to make it work. > > > > On Sat, Oct 23, 2010 at 2:03 PM, Eloy Duran > wrote: > >> > >> Since an Array is a NSArray: http://bit.ly/de3kxd, maybe something > >> like the following? > >> > >> $ macirb > >> irb(main):001:0> a = ['apple', 'tuna', 'orange'] > >> => ["apple", "tuna", "orange"] > >> irb(main):002:0> indices = NSIndexSet.indexSetWithIndex(1) > >> => # > >> irb(main):003:0> fish = a.objectsAtIndexes(indices) > >> => ["tuna"] > >> > >> Eloy > >> > >> On Sat, Oct 23, 2010 at 1:18 PM, Pixoo wrote: > >> > Hi ! > >> > > >> > I'm trying to use a tableView with MacRuby. > >> > What I want to do is remove items from my data array based on the > >> > tableView > >> > selection. > >> > > >> > I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and > I > >> > don't know how to use it with my array. > >> > Can you give me some leads on the subject ? > >> > > >> > Thanks, > >> > > >> > ___ > >> > 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
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
Did you look at the examples in /Developer/Examples/Ruby/MacRuby There a few examples using NSView, I'd be curious to know what's missing. (the yml table example should help) - Matt Sent from my iPhone On Oct 23, 2010, at 6:05, Pixoo wrote: > Ok it worked \o/ > I'm pretty new at ObjC (therefore I use MacRuby :D) so I don't know NS > objects. > > Thanks again :) > > On Sat, Oct 23, 2010 at 2:43 PM, Eloy Duran wrote: > You’re right, I forgot to include the line that basically did: @items > -= fish. However, since an array is actually of the mutable type > NSMutableArray, you can use its API as well http://bit.ly/90436W. > > irb(main):007:0> a.removeObjectsAtIndexes(indices) > => ["apple", "orange"] > > If you find you need to work with NSIndexSet's a lot, you could go to > town and add this to NSIndexSet: http://gist.github.com/642166 > > HTH, > Eloy > > On Sat, Oct 23, 2010 at 2:14 PM, Pixoo wrote: > > That doesn't match what I need. > > Ok, here is what I have : > > > > My data is the @items variable which is an array of objects. > > My tableView is @tableView. > > The action is a reaction to a click on a remove button after a selection in > > the table. > > > > What I want to do is something like this : > > > > def removeItems(sender) > > indexes = @tableView.selectedRowsIndexes > > @items.delete_at(indexes) > > @tableView.reloadData > > end > > > > But I can't get a way to make it work. > > > > On Sat, Oct 23, 2010 at 2:03 PM, Eloy Duran wrote: > >> > >> Since an Array is a NSArray: http://bit.ly/de3kxd, maybe something > >> like the following? > >> > >> $ macirb > >> irb(main):001:0> a = ['apple', 'tuna', 'orange'] > >> => ["apple", "tuna", "orange"] > >> irb(main):002:0> indices = NSIndexSet.indexSetWithIndex(1) > >> => # > >> irb(main):003:0> fish = a.objectsAtIndexes(indices) > >> => ["tuna"] > >> > >> Eloy > >> > >> On Sat, Oct 23, 2010 at 1:18 PM, Pixoo wrote: > >> > Hi ! > >> > > >> > I'm trying to use a tableView with MacRuby. > >> > What I want to do is remove items from my data array based on the > >> > tableView > >> > selection. > >> > > >> > I used @tableView.selectedRowsIndexes but it returns a NSIndexSet and I > >> > don't know how to use it with my array. > >> > Can you give me some leads on the subject ? > >> > > >> > Thanks, > >> > > >> > ___ > >> > 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] slight bug on tutorial page
The tutorial page has the line: You can read a complete list of frameworks that ship with Mac OS X here. but there is neither a hyperlink nor other indicator of a list of frameworks there. -- Perry E. [email protected] ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] How to use NSIndexSet with tableView data
On 24/10/2010, at 1:43 AM, Eloy Duran wrote: > > If you find you need to work with NSIndexSet's a lot, you could go to > town and add this to NSIndexSet: http://gist.github.com/642166 Great minds think alike :) http://blog.acute-distress.com/post/830826884/macruby-is-awesome ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] Understanding Pointer objects
Hi,
I've been trying to play with using the Accessibility API to do some automated
testing.
>From what I have researched, I have to use some C functions that often need a
>reference passed to the them.
I am at a loss when trying to deal with Pointer objects. I've tried playing
with them and googling it, but I just cannot figure out how to turn a pointer
into a more useful type or to get what I want out of them.
For example, I can start like this:
framework 'Cocoa'
unless AXAPIEnabled() # only works if I include the parenthesis
puts 'Please enable Access for Assistive Devices first'
exit 2
end
mail =
NSRunningApplication.runningApplicationsWithBundleIdentifier('com.apple.Mail').first
mail_object = AXUIElementCreateApplication mail.processIdentifier
names = Pointer.new :object
AXUIElementCopyAttributeNames mail_object, names
But then how do I get the values out of the names pointer? For reference, I
found the functions in AXUIElement.h.
Thanks,
Mark
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Frameworks Help
Hi Again, I have spent some time with Nick's tutorial and I am looking into wrapping the framework I have been provided with and I have a few more questions. The framework I am working with is already compiled and not in an xcode file. I am guessing all I need to do is write the Objective-C wrapper? The other issue I am having is the framework only contains one header file which links out to a series of files contained in a system extension. Am I able to write my wrapper in an Objective-C class from within my macruby application or do I need to create a bundle and import that into my project. Thanks, Shaun On 2010-10-19, at 10:12 PM, Mario Steele wrote: > Hello Shaun, > > On Wed, Oct 20, 2010 at 12:00 AM, Shaun August > wrote: > Hi Robert, > > Thanks! That make sense. All those cocoa classes have capitals and they work > fine. I seem to be able to call from the framework but I am running into an > undefined method 'extern'. I have also read somewhere that extern doesn't > work with MacRuby. Is that correct? The framework I am dealing with is > calling C functions and I am having trouble accessing them. > > extern is a macro for the ld library, to export an API Address in the Dynamic > library, that can be access dynamically at run time. With Objective-C, or > more so specifically with MacRuby, you need to write a sort of thin wrapper > around C Functions in Objective C, in order to access said Functions. So if > the framework that you are working with, doesn't expose Objective C API > Functions, you'll need to write a thin wrapper in order to access them. See > the tutorial done by Nick Ludlam about wrapping the TagLib C Library, in > Objective C. You can find it here: > http://www.macruby.org/documentation/reading-an-mp3-with-macruby.html It's > best to read through the entire article, as it gives you information about > wrapping C Functions in Objective C, which is quite useful, when writing your > own wrapper. > > hth, > > Mario > > Thanks, > > Shaun > > > On 2010-10-19, at 8:26 PM, Robert Rice wrote: > > > Hi Shaun: > > > > Lower case method names is only a convention. MacRuby will work fine using > > upper case, i.e., constant, method names. > > I know because I only recently changed my project to conform to the > > convention. > > > > Bob Rice > > > > > > On Oct 19, 2010, at 7:17 PM, Shaun August wrote: > > > >> Hi There, > >> > >> I am attempting to work with a framework provided by a USB device > >> manufacturer and all of their method names start with capitols and I am > >> wondering about the easiest way to access these methods through macruby. I > >> remember reading somewhere about fixing the constants in Obj-C but I > >> cannot locate the information. > >> > >> Does anyone have any suggestions as to how to remedy this? Should I rename > >> every command in the framework? > >> > >> Thanks, > >> > >> Shaun > >> > >> ___ > >> 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 > > > > -- > Mario Steele > Lieutenant Commander 3 > XO - Geo 99 > XO - STO IFT Fleet > http://www.trekfederation.com > http://geo99.ruby-im.net > > ___ > 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
