MacRuby: The Definitive Guide: Ruby and Cocoa on OS X

By Matt Aimonetti

Want to construct local Mac OS X functions with a graceful, developer-friendly replacement to Objective-C? MacRuby is a perfect selection. This in-depth advisor exhibits you the way Apple’s implementation of Ruby provides entry to the entire beneficial properties to be had to Objective-C programmers. You’ll get transparent, distinct factors of MacRuby, together with speedy programming suggestions resembling prototyping.

Perfect for programmers at any point, this booklet is jam-packed with code samples and entire venture examples. should you use Ruby, you could faucet your abilities to use Interface Builder, Cocoa libraries, the Objective-C runtime, and extra. If you’re a Cocoa developer, you’ll enhance your productiveness with MacRuby.

  • Get up to the mark on MacRuby fundamentals, together with sessions and methods
  • Learn tips to use MacRuby with Apple’s Xcode developer suite
  • Delve into the primitive item sessions and knowledge varieties in origin Kit
  • Build event-driven consumer interfaces with the AppKit framework
  • Handle relational item endurance with the middle facts framework
  • Use complex MacRuby concepts, together with concurrency and sandboxing
  • Get examples for purposes utilizing Twitter and a situation net service
  • Embed MacRuby into current Objective-C applications

Show description

Quick preview of MacRuby: The Definitive Guide: Ruby and Cocoa on OS X PDF

Similar Development books

Introduction to Programming Using Python plus MyProgrammingLab with Pearson eText -- Access Card

Notice: sooner than buying, discuss with your teacher to make sure you pick out the proper ISBN. numerous models of Pearson's MyLab & studying items exist for every identify, and registrations are usually not transferable. To sign up for and use Pearson's MyLab & getting to know items, you may as well want a path identification, which your teacher will supply.

Ground Control: Fear and Happiness in the Twenty-First-Century City

While the figures say crime is falling, why are we extra nervous than ever? might our cities and towns be developing worry and distrust? extra estate is being in-built Britain than at any time because the moment global warfare - yet it truly is owned by way of inner most enterprises, designed for revenue and watched over through CCTV.

The Dragon's Gift: The Real Story of China in Africa

Is China a rogue donor, as a few media pundits recommend? Or is China aiding the constructing international pave a pathway out of poverty, because the chinese language declare? within the previous few years, China's relief application has leapt out of the shadows. Media studies approximately large relief applications, aid for pariah regimes, regiments of chinese language exertions, and the ruthless exploitation of employees and typical assets in a number of the poorest international locations on this planet sparked fierce debates.

The Coming Prosperity: How Entrepreneurs Are Transforming the Global Economy

Ours is the main dynamic period in human background. the advantages of 4 centuries of technological and organizational swap are finally achieving a formerly excluded international majority. this alteration will create large-scale possibilities in richer international locations just like the usa simply because it has in poorer nations now within the ascent.

Extra info for MacRuby: The Definitive Guide: Ruby and Cocoa on OS X

Show sample text content

New(:integer) s brief Pointer. new(:short) l lengthy Pointer. new(:long) C unsigned char Pointer. new(:uchar) I unsigned integer Pointer. new(:uint) S unsigned brief Pointer. new(:ushort) L unsigned lengthy Pointer. new(:ulong) f waft Pointer. new(:float) @ item Pointer. new(:object) or Pointer. new(:id) B Boolean Pointer. new(:boolean) # classification Pointer. new(:class) : selector Pointer. new(:selector) you could create guidelines by means of passing the logo identify as proven above, and in addition via passing the pointer style code as a string. you could dereference the pointer a similar means you entry an array in Ruby. you may also have a pointer to a number of values. here's the way you create a pointer with bounds: 158 | bankruptcy 8: One Step Deeper pointer = Pointer. new(:float, four) pointer[0] = 1. zero pointer[1] = 2. zero pointer[2] = three. zero pointer[3] = four. zero pointer[0] # => 1. zero pointer[1] # => 2. zero pointer[2] # => three. zero pointer[3] # => four. zero To assign a cost to the pointer, you should use this kind of equipment: pointer. assign(3. 2) # or pointer[0]= three. 2 if you use [] and []=, you need to be cautious to not try and entry or set a cost out of bounds. regrettably, there's no technique to discover a pointer’s bounds. Dereferencing tips is lovely effortless and used to be proven past: pointer = Pointer. new(:integer) pointer. assign(42) pointer[0] # => forty two you can even offset tips utilizing the + and the - equipment: pointer = Pointer. new(:long, 10) 10. times{|i| pointer[i] = i } pointer2 = pointer + 2 pointer2[0] # => 2 pointer2[1] # => three pointer2[2] # => four One scenario that calls for offsetting is while you're utilizing a learn procedure that accepts a pointer of bytes and returns the variety of bytes truly learn. you could set a pointer, cross it to the strategy, offset it, and go it back. here's a dummy instance of such an API: ptr = dataOut; fakeAPI(dataIn, dataInLength, ptr, dataOutAvailable &dataOutMoved); ptr += dataOutMoved; dataOutAvailable -= dataOutMoved; otherAPI(ptr, dataOutAvailable, &dataOutMoved); different types of Objective-C guidelines will not be at once supported via MacRuby: void tips and unknown style guidelines (also referred to as unsigned pointers). Let’s examine easy methods to paintings with those kinds. Void guidelines so much tools in APIs in keeping with CoreFoundation use tips to CFTypeRefs, which technically are tips to void (also often called void *). If a mode expects a void pointer argument, you could go a pointer of any style. tips | 159 Let’s examine an instance from the Accessibility API: extern AXError AXUIElementCopyAttributeValue ( AXUIElementRef point, CFStringRef characteristic, CFTypeRef *value); As you will find, this can be a C functionality that takes a pointer as its final argument. the cause of utilizing a pointer is that it'll carry the functionality end result after it’s known as and the caller can retrieve the outcome from the pointer. The striking factor with this functionality is that, as pointed out, it returns the retrieved information within the ultimate parameter (value), and hence calls for a pointer as that parameter. to exploit the strategy in MacRuby, create a variable (here named titlePtr) and assign it to an item pointer.

Download PDF sample

Rated 4.74 of 5 – based on 45 votes