Created
April 28, 2011 18:46
-
-
Save donthorp/947002 to your computer and use it in GitHub Desktop.
Examples: Buffer Blog Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a Buffer with initial length of 0 | |
var buffer = Ti.createBuffer(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a buffer with initial size of 512 bytes | |
var buffer = Ti.createBuffer({ length: 512 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buffer = Ti.createBuffer({ length: 512 }); | |
// Shrink it. | |
buffer.length = 256; | |
// Set to zero length and release underlying storage. | |
buffer.release(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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