Narwhal: write data

35 views
Skip to first unread message

cacaodev

unread,
Mar 10, 2012, 12:04:59 PM3/10/12
to objecti...@googlegroups.com
hey list,

I'm trying to support NSNib in nib2cib. In Apple nib files, NSNibs are represented as base64 data.
Inside NS_InitWithCoder: i can get the correct data with the correct bytes array. Then i need to write it in a file in order to nib2cib again the resulting nib.

I tried this:
    var utf16String =  CFData.bytesToUtf16String(data.bytes());
    require("file").write("NSNib.nib", utf16String, { charset:"UTF-16" }); // UTF-16 because ibtool requires it. right ?

But unfortunately i don't get the excpected content. The file exist but some characters differ from what i get using NSData writeToFile: and ibtool says the file is corrupted.  It's hard to say why: because of the bytes->string conversion or the writing process.
Is there something obvious i'm missing here ?

Another possibility would be to write data directly from the bytes array to avoid any problems with encoding. Is there a way to do this in narwhal ?

cacaodev

unread,
Mar 10, 2012, 12:10:19 PM3/10/12
to objecti...@googlegroups.com
I meant plutil says the file is corrupted when i try to convert it to a property list. The sub nib is already in a compiled format.

cacaodev

unread,
Mar 10, 2012, 6:13:46 PM3/10/12
to objecti...@googlegroups.com
self-answer: 
It's just require("file").write(path, bytesArray, options);

Diego Germán Vivero

unread,
Mar 16, 2012, 4:07:16 AM3/16/12
to objecti...@googlegroups.com
Hi , do you know howto read a large file, because in this form narwhal load all in memory first . is possible read a file step by step?
thank
Reply all
Reply to author
Forward
0 new messages