26. NSMutableArray *anArray = [
[NSMutableArray alloc] init
];
[anArray addObject:@"Element 1"];
[anArray addObject:@"Element 2"];
[anArray addObject:@"Element 3"];
//Use a for each loop to iterate
through the array
for (NSString *s in anArray) {
NSLog(s);
}
//Release the array
[anArray release]
35. Good to know
• Available commands for each
application are in a .sdef file
36. Good to know
• Available commands for each
application are in a .sdef file
• Terminal.app/Contents/Resources/
Terminal.sdef
37. Good to know
• Available commands for each
application are in a .sdef file
• Terminal.app/Contents/Resources/
Terminal.sdef
• gem rb-appscript (native extension
so not for MacRuby)
38. 1 <command name="do script" code="coredosc"
2 description="Runs a UNIX shell script or command.">
3 <cocoa class="TTDoScriptCommand"/>
4 <direct-parameter type="text"
5 description="The command to execute." optional="yes"/>
6 <parameter name="with command"
7 description="Data to be passed to the Terminal..."
8 code="cmnd" optional="yes" hidden="yes">
9 <cocoa key="Command" />
10 <type type="text" />
11 <type type="any" /> <!-- support null case -->
12 </parameter>
13 <parameter name="in"
14 description="The tab in which to execute the command"
15 code="kfil" optional="yes">
16 <cocoa key="Target" />
17 <type type="tab" />
18 <type type="window" />
19 <type type="any" /> <!-- support null case -->
20 </parameter>
21 <result type="tab"
22 description="The tab the command was executed in." />
23 </command>
24
72. 1 #!/usr/bin/env macruby
2
3 worker_queue = Dispatch::Queue.new(
4 'ch.huesler-informatik.scotrubyconf.gcd'
5 )
6 group = Dispatch::Group.new
7
8 0.upto(10) do |i|
9 puts "Dispatch #{i} to GCD"
10 worker_queue.async(group) do
11 puts "working on #{i}"
12 end
13 end
14 puts "waiting for gcd"
15 group.wait
16 puts "done"
17
73. 1 #!/usr/bin/env macruby
2
3 worker_queue = Dispatch::Queue.new(
4 'ch.huesler-informatik.scotrubyconf.gcd'
5 )
6 group = Dispatch::Group.new
7
8 0.upto(10) do |i|
9 puts "Dispatch #{i} to GCD"
10 worker_queue.async(group) do
11 puts "working on #{i}"
12 end
13 end
14 puts "waiting for gcd"
15 group.wait
16 puts "done"
17
74. 7
8 0.upto(10) do |i|
9 puts "Dispatch #{i} to GCD"
10 worker_queue.async(group) do
11 puts "working on #{i}"
12 end
13 end
14 puts "waiting for gcd"
15 group.wait
16 puts "done"
17
76. 1 #!/usr/bin/env macruby
2
3 group = Dispatch::Group.new
4 result = []
5 1.upto(10).each do |i|
6 Dispatch::Queue.concurrent.async(group) do
7 sleep 2
8 result << i
9 end
10 end
11 group.wait
12 puts result.inspect
83. Details
• MacRuby has issues with void
pointer (patch pending)
84. Details
• MacRuby has issues with void
pointer (patch pending)
• Use objective c wrapper instead
(dynlib or bundle)
85. Details
• MacRuby has issues with void
pointer (patch pending)
• Use objective c wrapper instead
(dynlib or bundle)
• Generate metadata to make it
work
86. Details
• MacRuby has issues with void
pointer (patch pending)
• Use objective c wrapper instead
(dynlib or bundle)
• Generate metadata to make it
work