Skip to content

Instantly share code, notes, and snippets.

@donthorp
Created April 28, 2011 18:46
Show Gist options
  • Save donthorp/947002 to your computer and use it in GitHub Desktop.
Save donthorp/947002 to your computer and use it in GitHub Desktop.
Examples: Buffer Blog Post
// create a Buffer with initial length of 0
var buffer = Ti.createBuffer();
// create a buffer with initial size of 512 bytes
var buffer = Ti.createBuffer({ length: 512 });
var buffer = Ti.createBuffer({ length: 512 });
// Shrink it.
buffer.length = 256;
// Set to zero length and release underlying storage.
buffer.release();
var buffer = Ti.createBuffer({ length: 2 });
buffer[0] = 1;
buffer[1] = 3;
var buffer2 = Ti.createBuffer({ length: 1 });
buffer2[0] = 2;
buffer.insert(buffer2, 1);
// writes 123
Ti.API.info(String(buffer[0]) + String(buffer[1]) + String(buffer[2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment