performSelector in RubyCocoa
I had a lot of trouble finding documentation for this. If you want to make a call on the main thread in RubyCocoa, the format is something like:
performSelectorOnMainThread_withObject_waitUntilDone('method_name:', object, true)
So two things that took me a while:
- method_name has a trailing colon.
- The object the has the method you want to call should be the second argument. I got it in my head it should be the first for some reason.
Read table row-by-row in ruby
I needed to export some data from a huge data table. Iterating through MyModel.find took too long and too much ram, so I went straight to the db instead.
Example code was tough to find, so here's an example:
sql = "select * from #{ MyModel.table_name }"
MyModel.connection.execute(sql) do |handle|
handle.fetch do |row|
# row is an array of values
... export row ...
end
end
