pass an array objects in Corona with class

I'm creating an app with Corona structured in Class and I have a problem when I want pass an array objects for create an object. I have this:


local SurpriseBoxClass = require("SurpriseBox")
local BoxClass = require("Box")

local box1 ='palo', 'images/chestClose.gif', 'OPEN')
local box2 ='moneda', 'images/chestClose.gif', 'OPEN')
boxes = { box1, box2 }

local game =


local SurpriseBox = {}
local SurpriseBox_mt = { __index = SurpriseBox }

 local object = {
   boxes = boxesAux
 return setmetatable( object, SurpriseBox_mt )

The problem is when I want to print the content of array in a method of SurpriseBox, and the program said me that the array is nil if for example I do this:


What can I do?



Lua tables are 1-based.

Try print(boxes[1], boxes[2]).

It will print the table id. If you need to print the contents of the table, you must iterate over its fields, or use a custom printer that does it for you (see "Print a table recursively").

Need Your Help

Core Data: Fetched Results Controller causing over release/crash

objective-c ios core-data nsfetchedresultscontrolle nsentitydescription

I am using core data, and have a UITableViewController which loads the data from core data. This is a modal view and if I load the modal view for the third time, it crashes with EXC_BAD_ACCESS.

jQuery Ajax SyncLock

jquery ajax synclock

I have a couple of buttons that users can click to load content with jQuery's $.ajax. All the buttons load the content into the same div tag. The problem is that if users click multiple times quick...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.