I’ve never tried to use io.write like that. However, with iOS 6.0, Apple broke how content written to STDOUT shows up in the console log (it doesn’t). We patched print to use NS_LOG to write things out. I suspect that io.write() wasn’t patched for this purpose.
Anyway, to solve your immediate problem, I’m rather fond of this block of code (taken from the Community code)
function M.print\_r ( t )
local print\_r\_cache={}
local function sub\_print\_r(t,indent)
if (print\_r\_cache[tostring(t)]) then
print(indent.."\*"..tostring(t))
else
print\_r\_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] =\> "..tostring(t).." {")
sub\_print\_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
print(indent.."["..pos..'] =\> "'..val..'"')
else
print(indent.."["..pos.."] =\> "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
end
if (type(t)=="table") then
print(tostring(t).." {")
sub\_print\_r(t," ")
print("}")
else
sub\_print\_r(t," ")
end
print()
end
print_r is the PHP way of dumping a table, ergo it’s name. I tuck this puppy away in a file I copy from project to project so I always have it available. Joshua also added a new printTable() function in the Google Push Notification sample app in build 993 that will do the same thing.
[import]uid: 199310 topic_id: 34304 reply_id: 136373[/import]